07-16-2019 07:05 PM - edited 07-16-2019 07:09 PM
Hi, friends:
I'm building a communication between PC and RaspberryPi by UDP protocol. In PC part, a labview vi is running and it will firstly send a trigger signal of "yes" to the RPi part, whereas in the RPi part, after it received the trigger signal (yes), it will generate a decimal number and send it back to PC. Finally, the PC will receive that number and show it. The whole logic is shown in the following fig.
The weird thing is when I run the vi in PC part with the "highlight" mode (that bulb icon), everything is good, which means it can send out the trigger signal, and receive the returned data. However, if I disable the "highlight" mode, the vi will stop at the "UDP read".
Another thing is, if I only send the trigger signal and don't read the returned data (disable the "udp read"), the whole thing will run well too.
I believe the problem is related to the time interval things. For example, if I let the "wait" time in Vi as 10 seconds, the whole communication seems good, but that time interval is too big.
At last, there is a while loop in the RPi part (by python code), which is used to generate the required data. At the end that while loop, the code will sleep by 1.5 seconds.
So please give me some help on my problem. Deep appreciated for any comments.
07-17-2019 01:14 AM
07-17-2019 06:37 AM
There is no errors generated. The code just stopped there. I think the reason is in the Rpi part, the python code did not receive the trigger signal, so it stopped there, and in pc part, after sent out the trigger signal, the code will move to "read", but no data would come from rpi, so it will wait there.
The question is I don't know why the rpi part will miss the trigger signal.
07-17-2019 06:46 AM
07-17-2019 06:49 AM
I tried...
I will attach the python code in the Rpi part sooner.
Thanks a lot for reply.
07-17-2019 07:01 AM
Instead of UPD, maybe you should use TCP. TCP adds a little overhead, but that transmission is a lot more reliable. For the times you are mentioning, the TCP overhead will be negligible.
07-17-2019 07:28 AM
Yes, the tcp will be more reliable. However, the rpi has already used the tcp protocol for another connection with a fpga board. I have not much choice. Maybe serial communications is another choice?
07-17-2019 07:32 AM
07-17-2019 08:03 AM
Wow, you mean I can connect both fpga and pc by tcp protocol simultaneously? I guess I need to use multi threads? If so, how do I synchronize these two steps?
Maybe I didn't make my point clear. I use the pc to send a trigger signal to rpi, and when rpi received the trigger signal, it will connect to the fpga and get data from it, then, rpi will send the data back to pc.
Hopefully I make my point clear this time.
07-17-2019 08:10 AM
Hi ice,
you mean I can connect both fpga and pc by tcp protocol simultaneously?
In our lab we have about a dozen computers connected to the same LAN and they all can share information using TCP or UDP.
All our office computers share the same network…
If so, how do I synchronize these two steps? …
I use the pc to send a trigger signal to rpi, and when rpi received the trigger signal, it will connect to the fpga and get data from it, then, rpi will send the data back to pc.
What do you need to sync here? Each device waits for another device, there is nothing "in sync"!
(It's rather a statemachine you need here…)