Post by ric24 on Jan 2, 2024 16:52:02 GMT -5
Hi,
I am trying to read data from the serial output of an Arduino circuit via its USB.
The problem is that after more than about 50 characters some start missing until nothing is received any more.
However the first characters are received and stored OK on an output file on the PC .
The problem is that after more than about 50 characters some start missing until nothing is received any more.
However the first characters are received and stored OK on an output file on the PC .
As I couldn't find the reason for that I tried to split the program in an initial short section, close the ports and then reopen as if the program was started again and add the new data to the output file, opened in APPEND mode. No characters are found added to the file, although if I write some data to it they are appended, no problem.
So it seems to be a problem with the serial communication, maybe I have to change something either in the Liberty program or in the Arduino software.
Any suggestion would be gratefully appreciated. It is really my first program so maybe some detail in the setup is not right.
The Arduino data (not checked on the scope yet) should be coming out at about a 50 ms interval.
The output bytes should be at 9600,n,8,1 plus CR LF
The code I have tried is below:
-----------------------------------------------------------------------
Com = 64000
open "com5:9600,n,8,1" for INPUT as #GSR
open "C:\Users\User\Documents\FROMGSR.txt" for output as #OUTPUTFILE
FOR J=1 TO 50
NUM$ = INPUT$ (#GSR, 1)
print #OUTPUTFILE, NUM$
NEXT J
close #GSR
close #OUTPUTFILE
PRINT "FIRST ROUND DONE"
REP = 1
[CYCLE]
open "com5:9600,n,8,1" for INPUT as #GSR
open "C:\Users\User\Documents\FROMGSR.txt" for APPEND as #OUTPUTFILEA
FOR J=1 TO 50
NUM$ = INPUT$ (#GSR, 1)
print #OUTPUTFILEA, NUM$
NEXT J
REP = REP +1
IF REP > 3 THEN GOTO [GETOUT]
close #GSR
close #OUTPUTFILEA
GOTO [CYCLE]
[GETOUT]
PRINT "END OF CYCLES"
close #GSR
close #OUTPUTFILEA
END
open "com5:9600,n,8,1" for INPUT as #GSR
open "C:\Users\User\Documents\FROMGSR.txt" for output as #OUTPUTFILE
FOR J=1 TO 50
NUM$ = INPUT$ (#GSR, 1)
print #OUTPUTFILE, NUM$
NEXT J
close #GSR
close #OUTPUTFILE
PRINT "FIRST ROUND DONE"
REP = 1
[CYCLE]
open "com5:9600,n,8,1" for INPUT as #GSR
open "C:\Users\User\Documents\FROMGSR.txt" for APPEND as #OUTPUTFILEA
FOR J=1 TO 50
NUM$ = INPUT$ (#GSR, 1)
print #OUTPUTFILEA, NUM$
NEXT J
REP = REP +1
IF REP > 3 THEN GOTO [GETOUT]
close #GSR
close #OUTPUTFILEA
GOTO [CYCLE]
[GETOUT]
PRINT "END OF CYCLES"
close #GSR
close #OUTPUTFILEA
END
---------------------------------------------------------------
Many thanks
RIC24