This program reads a com port and plots a voltage reading sent to the com port via an A/D
QB64 always causes an Input Past End of File error when reading a com port but the included ON ERROR / Error handling sub takes care of it.
CLS
LOCATE 2, 20, , 0, 7
PRINT "COLLECTING DATA"
_DELAY 1
j = 0 ...
Search found 4 matches
- Fri Jan 19, 2018 10:31 pm
- Forum: QBasic / QuickBasic related
- Topic: Com port communication
- Replies: 6
- Views: 7372
- Wed Jan 03, 2018 7:00 pm
- Forum: QBasic / QuickBasic related
- Topic: Com port communication
- Replies: 6
- Views: 7372
Re: Com port communication
SOLUTIONS USED:
I used the OPEN FOR INPUT command and Z$=INPUT(LOC(2),#2) which I knew would result in an INPUT PAST END OF FILE error. I had to use LOC instead of LOF b/c LOF was always =0 and my routine returned LOC = a valid number. just before the Z$= INPUT command I added the line ON ERROR GOTO ...
I used the OPEN FOR INPUT command and Z$=INPUT(LOC(2),#2) which I knew would result in an INPUT PAST END OF FILE error. I had to use LOC instead of LOF b/c LOF was always =0 and my routine returned LOC = a valid number. just before the Z$= INPUT command I added the line ON ERROR GOTO ...
- Sun Dec 17, 2017 12:29 am
- Forum: QBasic / QuickBasic related
- Topic: Com port communication
- Replies: 6
- Views: 7372
Re: Com port communication
I have since added the following lines after the _Delay .25 line.
getdata:
bytes% = LOC(2) ' Check receive buffer for data
IF bytes% = 0 THEN GOTO getdata ' After more than 300 thousand of getdata cycles it continues
Now EOF is still -1 but LOC is 17 and LOF still shows 0
How can LOF be 0 if there ...
getdata:
bytes% = LOC(2) ' Check receive buffer for data
IF bytes% = 0 THEN GOTO getdata ' After more than 300 thousand of getdata cycles it continues
Now EOF is still -1 but LOC is 17 and LOF still shows 0
How can LOF be 0 if there ...
- Sat Dec 16, 2017 8:05 pm
- Forum: QBasic / QuickBasic related
- Topic: Com port communication
- Replies: 6
- Views: 7372
Re: Com port communication
I have an A/D converter that has placed the following characters in Com Port #3: Voltage = 1.2, *
I am using the following QB64 code to read the serial data:
‘ ** Wipe out old messages
Z$ = ""
OPEN "Com3:9600,n,8,1,ds0,cs0,rs" FOR INPUT AS #2
_DELAY .25 ' Delay to let Com Port settle
PRINT "EOF ...
I am using the following QB64 code to read the serial data:
‘ ** Wipe out old messages
Z$ = ""
OPEN "Com3:9600,n,8,1,ds0,cs0,rs" FOR INPUT AS #2
_DELAY .25 ' Delay to let Com Port settle
PRINT "EOF ...