Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Receive byte with data 0

Status
Not open for further replies.

mcs51mc

Member
Hey there,

I want to send some data from a µC board to a PC via RS232.
On the PC there is a VB6 application using MSComm control (properties in attached file RS232-02.jpg)
The µC send 24 bytes of data.
The first bytes of data are 0, 5, 255, 0, 10, 255, 0, 15, 255, 13, 35, 255, 13, 40, 252, 13, 45, 253, …

I encounter problems receiving the bytes with data “0”, zero.
Like you can see in file RS232-01.jpg all bytes are present except the three “0” bytes from position 1, 4 and 7.

Please notice that the software received only 21 bytes while the µC sends 24.
I suppose MSComm filtered these bytes out.
How do I tell MSComm to also pass bytes with “0” data to the input buffer?

I already tried with InputMode set to comInputModeBinary but with even worse result, mixed up data.

Thanks a lot for reading this
Even more thanks for a solution
 

Attachments

  • RS232-01.jpg
    RS232-01.jpg
    32.2 KB · Views: 108
  • RS232-02.jpg
    RS232-02.jpg
    28.7 KB · Views: 127
Easiest way is to convert all the data to ASCII, so send zero as the ASCII character '0', and 255 as the string '255' (or do it as hexadecimal ASCII) - this does mean you send more data, but it's fool proof, and avoids all the problems with RS232 control codes.
 
Try,
MSComm1.NullDiscard = false

I'd also set
InputLen=1
You currently have it set to zero which may work OK at the moment but will cause problems with some USB-RS232 converters.

Mike.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top