LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP Read undifined number of bytes

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

0 Kudos
Message 1 of 11
(2,477 Views)

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

0 Kudos
Message 2 of 11
(2,458 Views)

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.

Message Edited by JeanPierre on 05-13-2009 11:10 AM


LabVIEW, C'est LabVIEW

Message 3 of 11
(2,448 Views)

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.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 4 of 11
(1,983 Views)
Highlighted

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.


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 5 of 11
(1,975 Views)

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.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 6 of 11
(1,971 Views)

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).

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 7 of 11
(1,970 Views)

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

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 8 of 11
(1,969 Views)

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. Smiley Surprised

 

Please be more specific about your application:

 

  • Where is the data coming from?
  • Is it also LabVIEW and do you have control over the sending program?
  • How easy is it to tell if it is binary or formatted?
  • Can you tell from the data pattern once an entire set is received?
  • how long are the pauses between datasets?
  • What happens to the data after it is received? (stream to disk, scan, parse, etc.)

LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 9 of 11
(1,946 Views)

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

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 10 of 11
(1,915 Views)