Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDP example #74

Closed
marcobrianza opened this issue Oct 6, 2021 · 17 comments
Closed

UDP example #74

marcobrianza opened this issue Oct 6, 2021 · 17 comments
Assignees
Labels
bug Something isn't working

Comments

@marcobrianza
Copy link

I'm sending raw UDP packets to Serial Studio but they are not received.

It is not clear to me what is the "Host" filed meaning for the UDP connection, Is it the address where serialStudio binds locally?

can you please provide and example?

thank you
Marco

@marcobrianza marcobrianza added the enhancement New feature or request label Oct 6, 2021
@marcobrianza
Copy link
Author

hi, I was not considering that serial studio can also send data back. Now I get that Host and port a related to the remote host. So now I miss how to configure the UDP port Serial studio is listening on

@bigjohnson
Copy link

bigjohnson commented Oct 7, 2021

Hello,
I sucessfully send and receive data with Serial Studio using the Packet Sender software and the UDP protocol.
You must configure the programs with:

  1. Same ip network on both the software. (I insert this because in my test I used the same pc with localost and the real ip interface, and if i mixed ip It dont work)
  2. Open Packet Sender and check the UDP listen port on the bottom right info.
  3. Select in Serial Studio the Network UDP protocoll connection.
  4. Insert the Packet Sender UDP listening port on Serial Studio network udp port, and the Packet Sender PC address ( in my test I use the same PC and both address are the same)
  5. Connect the Serial Studio. (at this point nothing appen and nothing is received from Packet Sender because UDP is a stateless protocol)
  6. Send from Serial Studio one character with the send data to device, I use the + but it's not important.
  7. In the Packet Sender received packet check the From Port that is the Serial Monitor UDP port.
  8. Write the address and port of the Serial Monitor PC on the Packet Sender transmit data, set the protocol toUDP and send some characters
  9. The characters are displayed on the Serial Monitor console and the bidirectional connection is estabilished.

This procedure could be implemented in the esp8266 but I think thath could be usefull:

  1. Show somewhere in the application the UDP receiving port that change at every new connection/reconnection.
  2. Add an automatic one character + sending only for UDP network connections when the user push the Connect button.
  3. Add an automatic one character - sending only for UDP network connections when the user push the Disconnect button.

The caracters choice is not important, but they must be diferent.

I think this is the base for developing an esp8266 or other microcontroller network enabled UDP packet sender sketch.
I don't add the microcontroller implementation phases here because the post i soo long.
Thanks.

Alberto

@bigjohnson
Copy link

bigjohnson commented Oct 7, 2021

Actually I have a esp8266 working sketch with the moreOrLess protocol working.
That read the Serial Studio UDP port from the + character received, and stop sending tata with -
You can start stop it many times you like.
If you send a string the + or - characters must be the first, the other are ingnored in any position.
If I disconnect and reconnect it from Serial Studio I can re send the + character and the sketch refresh the ip and port sending the data to the new opened UDP port.
Soon I will publish the sketch.
Alberto

@bigjohnson
Copy link

The sketch: UDPss

Alberto

alex-spataru added a commit that referenced this issue Oct 8, 2021
@alex-spataru
Copy link
Member

Hi,

I implemented support for both socket types (TCP/UDP) because Qt provides an abstraction layer that allows me to threat sockets as files (e.g. use read() and write() functions). However, I did not take into account UDP sockets have specialized functions for connecting/binding to a host, which seems to cause a lot of issues with the UDP socket.

I just made some changes & tests that allow Serial Studio to communicate with UDP multicast groups, and will perform tests on P2P connections tomorrow.

I'll keep you updated on my progress on this thread.

@alex-spataru alex-spataru added bug Something isn't working and removed enhancement New feature or request labels Oct 8, 2021
@alex-spataru
Copy link
Member

@bigjohnson Btw, thanks a lot for your sketch! If I get an esp8266 I will totally test it!

@alex-spataru
Copy link
Member

Just a quick update, with the latest commit users can now select if they want to connect to a multicast group. Both IPv4 and IPv6 addresses are supported.

Finally, here is a screenshot with Serial Studio displaying raw mDNS messages on the console:

Screen Shot 2021-10-08 at 0 01 42

@alex-spataru
Copy link
Member

I just created a new release that fixes this issue. Please let me know how it works for you!

@marcobrianza
Copy link
Author

hello and thank you for working in the UDP feature. I still see there is only 1 port in the interface and I expected 2: one for the remote host and one where serial studio il listening, you can also use the same number for both but it is generally a problem if the 2 endpoints are on the same machine. I have also seen the the behaviour is the opposite as before. now the port is the one where serial studio is listening (and I can send data to it) but cannot sent data to the remote host. I hope all is clear. Marco

@alex-spataru
Copy link
Member

Hi @marcobrianza,

If I understand correctly, you would like to have an UDP configuration pane similar to this one:

Screen Shot 2021-10-21 at 16 40 45

Can you please confirm if this is the desired behaviour?

@alex-spataru
Copy link
Member

Update: Here is another screenshot with the labels changed for more clarity:

Screen Shot 2021-10-21 at 16 44 18

@alex-spataru
Copy link
Member

alex-spataru commented Oct 21, 2021

Update, I just implemented this feature. Here is a screen recording of me manually sending a DNS request for example.com from Serial Studio:

UDP_DNS_Test.mov

If possible, please download and install the continuous build to test if these changes work for your project.

@marcobrianza
Copy link
Author

hello, thank you for developing further his feature. The last panel with the 2 ports is a perfect interface.
I have tested the continuous build but unfortunately it does not transmit nor receive.
I will try later

@bigjohnson
Copy link

bigjohnson commented Oct 22, 2021

I also tested the last version and it don't works for UDP in both multicast and normal mode.
But with windows 10 with Multicast I see a Mysterious effect:

  1. opening the port in multicast with Packet Sender for esp8266 sketch testing.
  2. closing the Packet Sender program.
  3. open Serial Studio with udp Multicast on the same address and port it works.

Tested wit the today release, i lose the yesteday setup.

thanks

alex-spataru added a commit that referenced this issue Oct 25, 2021
@alex-spataru
Copy link
Member

alex-spataru commented Oct 25, 2021

Hi,

I just updated the code again & tested successfully with PacketSender on a Windows 10 VM. I also tested the multicast option with a mDNS service running on my LAN (which consists of my mobile phone and my laptop, the ping request was sent from my phone and Serial Studio received it successfully).

If possible, please download the latest continuous build and check if the latest commit fixes the problem for you too. The root cause of the issue seems to be that I did not define explicitly the flags used to bind the UDP socket. This explains why the UDP socket feature worked on macOS, but not on Windows.

Important change: In a similar manner to PacketSender, if you want the local UDP port to be automatically assigned by the operating system, just type "0" in the "local port" field.

Also, thanks a lot for the donation @marcobrianza! I really appreciate it :)

@marcobrianza
Copy link
Author

hello!, UDP works for me in both directions! thank you very much

@alex-spataru
Copy link
Member

hello!, UDP works for me in both directions! thank you very much

Glad to hear it, I just created a new release that includes these fixes and updated UI translations. If you are using the latest continuous build, there is no need to download the update again. The code and installers are exactly the same. If you still encounter issues with the UDP sockets, feel free to re-open this issue.

Thanks a lot for the bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants