Problem with sending Chr(128) - Chr(255) to a serial port device

aruangra

Member
Licensed User
Longtime User
Hello all

I am writing a software to communicate with a device via a serial port. I could send a single character of chr(0) - chr(127) and get the response from my device. But when sending chr(128), I got a communication error. It is the same for any character with the ascii code ranging from 128 to 255.

I use the following command:
serial.Output (Chr(Yag))
where Yag is a constant

I also checked the output string from my PPC using a RS232 terminal program. For chr(128) - chr(255), the string "?" was sent out from my PPC. This is not right.

How does Basic4PPC deal with chr(128) - chr(255) sent via a serial port? What is the workaround to send the string with the ascii code from 128 to 255?

Best regards,
Anat
 
Last edited:

aruangra

Member
Licensed User
Longtime User
Thank you very much. I replaced the original Serial2.dll by SerialEx.dll, but I still have the same problem with chr(128) - chr(255) when using the "output" method. What is the appropriate method that I should use?

Thanks,
Anat
 
Last edited:

agraham

Expert
Licensed User
Longtime User
The standard encoding of SerialEx is ASCII so that it defaults to the same as Serial2. To send strings with characters > 127 you need to set the Encoding property to suit the expectation of whatever you are talking to. There is a list in the Encodings topic of the help.

If if is binary data you are sending then the encoding is irrelevant and you should use Output2 or OutputBytes.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…