I made a typical program to send and receive data with TCP/IP protocol using this. LabVIEW sends 33 bytes to a microcontroller and receives 30 bytes. The TCP Read and Write functions in LabVIEW use strings as data types. So I should convert byte array to string and vice versa. Everything is OK except the "zero" number.
When the micro sends bytes to LabVIEW, the TCP read converts it to their ASCII equivalents, i.e 65 to "A". Everything is OK, except the "0" number because its ASCII equivalent is NULL and TCP read can not interpret it. Actually when micro sends 30 bytes with zero value, TCP thinks that nothing has been sent from server and generates an error: <65: TCP Read Error>.
How can I overcome this issue? One solution is to convert 8-bit numbers to 3-digit number (0 to 255) and send each digit as a byte.
As far as I know, TCP Read does no such conversion, or it would be totally useless to send binary data. Check the sending side to make sure things are being sent correctly.
What led you to this conclusion?
Micro sends data in uint_8 data format but data transmission is done in string format. I think I should add some termination characters to the end of bytes, such as CRLF.
You know from your other topic that you should post some code. i think something's messed up in the conversion, which should be really simple.
Actually I used the most simple code for TCP read and write. I've attached it.
Micro sends an array of uint_8. If I fill the array with something except 0, everything is ok. But putting a zero in array makes trouble in LabVIEW, as I said.
What makes you think the problem is on the LabVIEW side with VISA Read?
Perhaps the problem is on the microcontroller side and it doesn't know how to send out the null character? My understanding is that in C, the string datatype is terminated with a null character. So perhaps the microcontroller code is terminating your string prematurely.
Yes. There may be some problems in ethernet functions in micro. Actually I don't know what is wrong. I asked if someone had similiar experience.
I'd like to know the steps you took to conclude that it was an issue with some kind of ASCII translation issue. Not because I want to tear it apart, but because it may give us an insight into what is really happening.
I rechecked the program. The problem was in micro send function. C sprintf function can not interpret \n character. I should convert bytes to ASCII in micro. The bytes will increase in this way. I must send 69 bytes instead of 31 bytes.