05-13-2009 07:10 AM
Hello LabVIEW RT users
I'm trying to convert a java application to my LabVIEW RT Smart Camera
In my camera I have a working TCP server which reads and writes some data to/from a robot. My problem is that in LabVIEW i have to specify who many bytes I'm reciving to get it to work. But in my Java application the BufferedReader took care of this. I can't control what the robot is sending but it could be things like these strings
GET X
SET R 1
SET X 443
SET X 11
GET START
Somone who knows how I best handle this problem? I have tried to change the mode of the TCP read to CRLF but without succes
05-13-2009 09:17 AM
A.Rohde wrote:Hello LabVIEW RT users
I'm trying to convert a java application to my LabVIEW RT Smart Camera
In my camera I have a working TCP server which reads and writes some data to/from a robot. My problem is that in LabVIEW i have to specify who many bytes I'm reciving to get it to work. But in my Java application the BufferedReader took care of this. I can't control what the robot is sending but it could be things like these strings
GET X
SET R 1
SET X 443
SET X 11
GET START
Somone who knows how I best handle this problem? I have tried to change the mode of the TCP read to CRLF but without succes
Get the spec on the protocol used by the camera.
TCP/IP is just a pipe that moves data. There has to be a way of determining the number of bytes in the packet. I suspect it prepends the byte count to the message.
Ben
05-13-2009 10:07 AM - edited 05-13-2009 10:10 AM
Try the Mode Immediate. From the help:
Immediate—Waits until the function receives any bytes. Waits the full timeout only if the function receives no bytes. Returns the number of bytes so far. Reports a timeout error if the function receives no bytes.
You can put a large number of bytes to read, the function will return as soon as a packet is received.
LabVIEW, C'est LabVIEW
09-14-2012 11:13 PM - edited 09-14-2012 11:14 PM
HI all,
I am also facing same kind of problem & as a soluntion i am also using IMMEDIATE read mode. In my application i may need at the max 1MB of data but occasionaly. Hence i have given number of bytes to be read as 3000000(1MB * 2(for ascii)). But what i see that in my application i am able to read at the max 3752 bytes. Not more than that.
If you solved this problem that let me know.
Thanks.
09-15-2012 03:08 AM
3000000(1MB * 2(for ascii))
I don't get your math. How much is that as an actual number? It cannot be 6000000MB (6TB!!), right?
Can you show us some code?
"Immediate" mode returns immediately if any bytes (one or more!) have been received, so to get all data you probably need to loop. Do you? What was your reasoning to select immediate mode? Does not make a lot of sense.
09-15-2012 04:07 AM
I think when the number of bytes to be read is not fixed than the reading mode should be CRLF. Apart from this no other mode is useful.
09-15-2012 04:10 AM
3000000 that is just a number for testing.For termination immediate is enough. total number of bytes to be read is 1Mb in hex. But the communication will be in ASCII mode hence *2. In real time it wont cross 2097152 + overhead bytes(15 approx).
09-15-2012 04:32 AM
I selected immediate because data to be read over TCP will be max 1MB*2. But as i said occansionally. otherwise it will be 100,200,1500,3000 bytes as per the user request. Hence i dont have any other option. I cant use standard or buffered because no of byte is not fixed. termination character is other looks like good option, I opted for this just becasue i want to avoid the termination character.but when i am tersting in immediate mode number of bytes at a time i can read is 3752 because i dont know why ??????
Hence i am going for temination(CRLF).
Do you have any alternative....will be great
09-15-2012 11:51 AM - edited 09-15-2012 11:51 AM
If you have 1MB if random binary data, is highly likely that there will be a CRLF embedded somewhere by chance, so that won't work. None of your vague comments and suggestions make any sense so far. This is most likely a very simple problem that you are way overthinking and trying to overengineer. Billions of bytes of variable lenght data are transmitted every second across the world and nobody else seems to have these problems. 😮
Please be more specific about your application:
09-17-2012 12:37 AM
Thaks for your valuable reply as you said - "None of your vague comments and suggestions make any sense so far." I dont feel like answering your question.
Thanks anyways