Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

ascii data capture at serial comm port

dickbuckdickbuck Member Posts: 3
I am trying to capture & process ascii data coming into a com1 port using the following open statement:
OPEN "COM1:9600,N,8,1,ASC,RB4096" FOR INPUT AS #2 ' open com port

after opening an output file I turn com(1) on then set up a loop:

ix = 1

DO WHILE ix <> 0
ON COM(1) GOSUB 2000
LOOP

at 2000 I do a line input #2 and get the data ok [except for a couple missing characters at the end]

the data is triggered by a print command [redirected to the serial port] through a null modem connection.

My problem is that while I get the data, I can't tell when there is no more data coming thru com1 so I can transfer out and process the file.

Bottom line, I guess, is how do you query the status of a com port in qb4.5?

Thanks

Comments

  • mstechcamstechca Member Posts: 64
    you can try reading one byte at a time. If the values are always 0's, then there is no data coming through. Try it with an empty com port. I think with the open statement you are using, use "OP1" instead of "OP0", that way Qbasic can tell if the device is functioning. If not, Qbasic will report a time-out error. I do assume that Qbasic expects initial data from the port.
    email: mstechcae@webcity.ca

  • dickbuckdickbuck Member Posts: 3
    : you can try reading one byte at a time. If the values are always 0's, then there is no data coming through. Try it with an empty com port. I think with the open statement you are using, use "OP1" instead of "OP0", that way Qbasic can tell if the device is functioning. If not, Qbasic will report a time-out error. I do assume that Qbasic expects initial data from the port.
    : email: mstechcae@webcity.ca
    :
    :
    Thanks for the reply; I am now reading 1 byte at a time and checking for a null CHR$(0) and that seem to work for me.
  • dickbuckdickbuck Member Posts: 3
    : you can try reading one byte at a time. If the values are always 0's, then there is no data coming through. Try it with an empty com port. I think with the open statement you are using, use "OP1" instead of "OP0", that way Qbasic can tell if the device is functioning. If not, Qbasic will report a time-out error. I do assume that Qbasic expects initial data from the port.
    : email: mstechcae@webcity.ca
    :
    :
    Thanks for the reply; I am now reading 1 byte at a time and checking for a null CHR$(0) and that seem to work for me.
Sign In or Register to comment.