Question: I'm trying to get Data from a Barcode terminal connected via RS232 to the Tibbo DS100. I get the Data, but I get it sometimes all in one packet and somtimes in several packets.
How can I know that I got the last data bytes? Does the Tibbo makes a Close connection? I get some of the data in few packeges and don't know how to paste them.
Answer: The data is split up because that's what TCP communications do. An inherent part of TCP is breaking packets up and re-assemebeling them on the other end.
However, there are two possible solutions for this:
Use a START char and a STOP char for the barcode scanner. You can configure the scanner itself using the manual that came with it, with barcode scan codes inside. This way, you can tell your program that a packet starts with “X” (just an example) and ends with “Z”, and that all the data in between is just one message, and no matter in how many packets it comes. Of course, make sure you select characters which don't appear in the barcode labels themselves (don't choose a number or anything like that, which might show up on a barcode label).
Another option is using UDP. If you set the transport protocol to UDP (and listen on a UDP socket, of course), you can make the whole message come as one packet.
You do this by using the STOP character, but this time configuring it on the DS as well, as described in the following links:
But be warned: UDP is a less reliable medium. It's a connectionless protocol– this means that it just sends the packets away, and doesn't really check if they arrived.
Also, if you're across a router (or several routers like on a large WAN), the UDP packets might not actually make it to the other side. Routers and other switching equipment usually prioritize packets, and give a higher priority to TCP. So if the router is under load when it gets your UDP packet, it might just drop it in favor of other, TCP packets.
In short, what you should do is:
Set the reader to use START and STOP chars.
Leave the DS as TCP.
Make your program understand the data stream with the START and STOP chars.
If for some reason this doesn't work for you, try the UDP option.
And if all else fails, you can always fill out a support request form.