-
Notifications
You must be signed in to change notification settings - Fork 237
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
(Help) UDP by esp32 #415
Comments
You may mix things a bit. NMEA2000 library core takes care of NMEA2000 (CAN) bus communication and necessary required tasks. On UDP stream you have just data coming, which means that you need some kind of format converter instead of full library. UDP stream format is not specified as standard. So you may have:
Note that UDP data can be in what ever format sender has decided to use. Even bare frame format can be ascii or binary. |
Sorry Timo, i try to expain better. NMEA2000.SetForwardStream(&Udp); |
You can just open stream and set it as forward stream. You do not need to use beginPacket/endPacket on loop. That method sends all messages to the stream, which is a bit wasting of resources, if you do not want to analyze all messages. Other method is just handle each message and on message handler send only selected messages with tN2kMsg::SendInActisenseFormat
Remember to use AsyncUDP library to avoid blocking. |
Thanks Timo. But how I can define in this case the IP address and port where send the udp packets? |
When you open UDP stream. I have tested only broadcast and just kept udp open all the time. If you need to use addressed, you have to test that can it be open all the time as far and if connection closes, then try to reopen. If you open/close it all the time, you have to test that it does not block loop and possibly move sending to an other thread. If you need to use other thread, you have to put received messages to some list and take care of data locking with mutexes. |
My IP esp32 is 192.168.0.15 and I want to send the udp packages in all my internal network 192.168.0.255 at the 5000 port. |
Then you simply use tUDPBroadcastStream, open it at setup and either use forward stream or on message handler as I wrote above. |
Hi Timo, it work but seem to be some problems. the stream (text) seem to be wrong in the udp side, serial side it is fine. I attach two filese with log of both serial and udp. |
You have set: NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); |
Yes i Know, but i suspect the Actisense format is wrong too on UDP stream, if you check the two files in text format, serial stream is ok UDP stream is wrong |
Both are not in actisense format. They are both in text format, which is only for testing. If you use forwarding, then you have to use fwdt_Actisense format or remove line I mentioned. If you use messagehandler, then use N2kMsg.SendInActisenseFormat(&outputStream); |
The UDP stream in actisense format seem to be very fine (respect to Text stream). I attach a log file. |
Is possible implement the UDP stream by esp32 of received messages? some software are able to read this UDP stream and use N2K messages.
The text was updated successfully, but these errors were encountered: