Page 1 of 1

Sending Data Thru Com Port Problem

Posted: Sun Dec 05, 2010 8:15 am
by Nelson
I am sorry that I am not well versed in Qbasic.

I am writing a progarm to send data to the serial port in order to control a device which is used in electronics. I must send various characters which is all working except for one problem. I cannot seem to send a CHR$(19).

I am using com port monotoring software to view what is happening. I can send any character to the port, but when I send CHR$(19), is simply skips.

For instance, if I send a string such as CHR$(17); CHR$(18); CHR$(19); CHR$(20), the communication will send three bytes, leaving out the 19.

I am using OPEN "COM1:9600,N,8,!,CD0,CS0,DS0,OP0, RS,RB512,TB512" FOR RANDOM AS #1. I have experimented with other formats, but nothing seems to work.

Any clues?

Posted: Sun Dec 05, 2010 5:12 pm
by burger2227
Control Character 19 is used in the COM port to designate XOFF to end a transmission. Character 17 turns a transmission on as XON.

Why are you sending control characters? They are used to CONTROL things.

ASCII codes from 0 to 31 are control characters. Send something else.

Ted

Posted: Sun Dec 05, 2010 5:31 pm
by Nelson
Thank you for the reply.

I am working with reading and writing to RFID devices using a reader/programmer. I must have the ability to send varied data including all possible 256 possible byte combinations, as the data I am writing can have any value.

I have the origianl software which comes with the device I am working with, and I am sniffing the commands. I am using Qbasic to recreate software which will be dedicated for my use.

The OEM software is sending commands and data, in part being 13hex (CHR$(19) through the port just fine. However, I have now tried for a few hours various ways to send that character with no luck.

Would be grateful for any help.

Thanks.

Posted: Sun Dec 05, 2010 5:46 pm
by burger2227
The data link escape character (DLE) was intended to be a signal to the other
end of a data link that the following character is a control character such as
STX or ETX. For example a packet may be structured in the following way:

(DLE) <STX> <PAYLOAD> (DLE) <ETX>.

Send CHR$(16) with both CHR$(17) and CHR$(19) and see what happens.

I've never tried that though.

Posted: Sun Dec 05, 2010 10:28 pm
by Nelson
Thank you for the advice. I did try that and no go though.

I also tried using the OUT statement to write 19 directly to the port with no luck.

Seems there simply must be a way.

Posted: Mon Dec 06, 2010 12:10 am
by burger2227
You could try sending HEX$ values, but that would require 2 bytes per value. Convert the value with HEX$(number%)
and send two characters. Add a "0" if the length is only 1. When it is received, add the two characters together and
add &H to VAL(&H1F) to get the numerical value. All you will be transmitting is the text numbers
0 to 9(ASCII codes 48 to 57) and A to F(65 to 70) .

Take a look halfway down this link:

http://www.lvr.com/serial_ports_dotnet.htm