Strugling with UDP broadcast input in RPi

66 views
Skip to first unread message

Phil Wild

unread,
Jan 21, 2022, 9:25:00 AM1/21/22
to kp...@googlegroups.com
Hi!

I've had kplex 1.4 running nicely for a couple of years. I want to add another input. This is a Iveco engine control panel.

It UDP broadcasts to port 65501

The messages look like this:
$P_MA,375,255,1,220121202551,0,0,0,220121202551,0,0,,100,100,,,,,,,,,,,,,,,,,53,44,,,,,,,,,,,,,,,,,,,,,,,,32,0.8,0,1,0.0,32,25.9,403,,0,0,0,0,31,0,1.0,,,,,,,,,0,0.0,0,0,0.0,0,0.0,0,,0,0,0,0,0,0,1.0,,,,,,,,,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,-3159.94023,+11532.74904,105.2,0.5, 0.0, 0.0,,,77FFF700000000000000000000000000000000,0.0,0.0,1, 10773.9, 11049.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*31520
$P_MA,375,255,1,220121202551,0,0,0,220121202551,0,0,,100,100,,,,,,,,,,,,,,,,,53,44,,,,,,,,,,,,,,,,,,,,,,,,32,0.8,0,1,0.0,32,25.9,403,,0,0,0,0,31,0,1.0,,,,,,,,,0,0.0,0,0,0.0,0,0.0,0,,0,0,0,0,0,0,1.0,,,,,,,,,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,-3159.94023,+11532.74904,105.2,0.5, 0.0, 0.0,,,77FFF700000000000000000000000000000000,0.0,0.0,1, 10773.9, 11049.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*31520
$P_MA,375,255,1,220121202550,0,0,0,220121202550,0,0,,100,100,,,,,,,,,,,,,,,,,53,44,,,,,,,,,,,,,,,,,,,,,,,,32,0.8,0,1,0.0,32,25.8,403,,0,0,0,0,31,0,1.0,,,,,,,,,0,0.0,0,0,0.0,0,0.0,0,,0,0,0,0,0,0,1.0,,,,,,,,,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,-3159.94023,+11532.74904,105.2,0.5, 0.0, 0.0,,,77FFF700000000000000000000000000000000,0.0,0.0,1, 10773.9, 11049.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*59008
$P_MA,375,255,1,220121202550,0,0,0,220121202550,0,0,,100,100,,,,,,,,,,,,,,,,,53,44,,,,,,,,,,,,,,,,,,,,,,,,32,0.8,0,1,0.0,32,25.8,403,,0,0,0,0,31,0,1.0,,,,,,,,,0,0.0,0,0,0.0,0,0.0,0,,0,0,0,0,0,0,1.0,,,,,,,,,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,-3159.94041,+11532.74906,105.2,0.1, 0.0, 0.0,,,77FFF700000000000000000000000000000000,0.0,0.0,1, 10773.9, 11049.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*2598
$P_MA,375,255,1,220121202549,0,0,0,220121202549,0,0,,100,100,,,,,,,,,,,,,,,,,53,43,,,,,,,,,,,,,,,,,,,,,,,,32,0.8,0,1,0.0,32,25.8,403,,0,0,0,0,31,0,1.0,,,,,,,,,0,0.0,0,0,0.0,0,0.0,0,,0,0,0,0,0,0,1.0,,,,,,,,,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,-3159.94053,+11532.74910,105.2,0.5, 0.0, 0.0,,,77FFF700000000000000000000000000000000,0.0,0.0,1, 10773.9, 11049.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*16502
I can see the packets being received via tcpdump


root@boat:/etc# tcpdump udp

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode

listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes

22:19:47.860730 IP 192.168.0.47.45781 > 192.168.0.1.65501: UDP, length 414

22:19:48.264046 IP 192.168.0.47.35888 > 192.168.0.1.65501: UDP, length 414

22:19:48.865393 IP 192.168.0.47.56662 > 192.168.0.1.65501: UDP, length 413

22:19:49.264160 IP 192.168.0.47.42392 > 192.168.0.1.65501: UDP, length 413

22:19:49.864019 IP 192.168.0.47.33611 > 192.168.0.1.65501: UDP, length 414

22:19:50.259460 IP 192.168.0.47.45834 > 192.168.0.1.65501: UDP, length 414

22:19:50.860621 IP 192.168.0.47.42233 > 192.168.0.1.65501: UDP, length 414

22:19:53.264060 IP 192.168.0.47.33387 > 192.168.0.1.65501: UDP, length 415

22:19:53.863695 IP 192.168.0.47.59235 > 192.168.0.1.65501: UDP, length 413

22:19:54.259068 IP 192.168.0.47.34855 > 192.168.0.1.65501: UDP, length 415


This is my config file


[global]

failover=GP***:0:axiom:60:usbgps

strict=no


[serial]

name=usbgps

#filename=/dev/serial/by-id/usb-FTDI_USB__-__Serial-if00-port0

filename=/dev/serial/by-path/platform-3f980000.usb-usb-0:1.3:1.0-port0

baud=9600

direction=in


[serial]

name=axiom

#filename=/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0

filename=/dev/serial/by-path/platform-3f980000.usb-usb-0:1.4:1.0-port0

baud=4800

direction=in


[serial]

name=engine

#filename=/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0

filename=/dev/serial/by-path/platform-3f980000.usb-usb-0:1.2:1.0-port0

baud=4800

direction=out

ofilter=+GP***:-all


[udp]

name=engine_in_udp

direction=in

optional=yes

address=192.168.0.255

type=broadcast

#device=eth0

port=65501

coalesce=yes


[file]

name=nmealog

direction=out

optional=yes

filename=/var/log/nmea.log

append=yes



[udp]

name=out_nav_udp

direction=out

optional=yes

#device=wlan0

address=192.168.1.255

port=2000

coalesce=yes

# srctag=input


I see other sources but never see the engine_in_udp data in nmealog or out_nav_udp


This is what I see with debug...



root@boat:/etc# /usr/bin/kplex -d3

kplex DEBUG: kplex starting, config file /etc/kplex.conf

kplex DEBUG: usbgps: opened serial device /dev/serial/by-path/platform-3f980000.usb-usb-0:1.3:1.0-port0 for input

kplex DEBUG: axiom: opened serial device /dev/serial/by-path/platform-3f980000.usb-usb-0:1.4:1.0-port0 for input

kplex DEBUG: engine: opened serial device /dev/serial/by-path/platform-3f980000.usb-usb-0:1.2:1.0-port0 for output

kplex DEBUG: udp interface engine_in_udp listening on 192.168.0.255, port 65501

kplex DEBUG: nmealog: opened /var/log/nmea.log for output

kplex DEBUG: out_nav_udp: output address 192.168.1.255, port 2000


Any suggestions as to what I'm doing wrong?


Thanks!


Keith Young

unread,
Jan 24, 2022, 4:07:29 PM1/24/22
to kplex
try adding:
strict=no

It's not going to be anything you're doing wrong: more likely something the device you're using is doing "non-standardly" or something I've done wrong :-)

I'm wondering whether the sentences are \r\n terminated.  adding -s0 -X to your tcpdump might give a clue but try strict=no first as that will accept a wider range of sentence terminators.

Phil Wild

unread,
Jan 25, 2022, 5:11:39 AM1/25/22
to kplex
Thankyou!

I already have that in my config file under [global]

Do I need to move it to the input?

I'll be in a position to capture a tcpdump later tonight so I'll report back.

Cheers

Keith Young

unread,
Jan 25, 2022, 7:36:15 AM1/25/22
to kplex
Sorry: my mistake: I just wasn't looking.  That should work.  Note that the coalesce=yes is redundant for an input-only interface (I should fix the documentation).

I've checked the code (it's a long time since I've looked at that bit) and it seems to default to the global value of strict if not specified in an interface definition

Keith Young

unread,
Jan 25, 2022, 5:29:43 PM1/25/22
to kplex
Sorry again.  Duh! a couple of glasses of wine and I see the blindingly obvious from your original post:
* Those sentences far exceed maximum NMEA sentence length
* I don't know what's going on there but the checksum is supposed to be 2 hex digits which those are not

So what is wrong is that those "sentences" are completely broken and not conforming to the rules of NMEA-0183

Phil Wild

unread,
Jan 25, 2022, 8:13:10 PM1/25/22
to kplex
Oh...
OK...
This data comes from an Iveco FPT engine control panel. I guess I'm stuffed and will need to figure out another way of capturing the information.
Just to close this off, here is the output of TCP dump. Each message is terminated with CRLF
Many thanks for your help!

08:58:58.652606 IP 192.168.0.47.43624 > 192.168.0.1.65501: UDP, length 422
0x0000: 4500 01c2 0000 4000 4011 b7aa c0a8 002f E.....@.@....../
0x0010: c0a8 0001 aa68 ffdd 01ae 22f8 2450 5f4d .....h....".$P_M
0x0020: 412c 3337 352c 3235 352c 312c 3232 3031 A,375,255,1,2201
0x0030: 3236 3030 3537 3135 2c30 2c30 2c30 2c32 26005715,0,0,0,2
0x0040: 3230 3132 3630 3035 3731 352c 302c 302c 20126005715,0,0,
0x0050: 2c31 3030 2c31 3030 2c2c 2c2c 2c2c 2c2c ,100,100,,,,,,,,
0x0060: 2c2c 2c2c 2c2c 2c2c 2c35 312c 3431 2c2c ,,,,,,,,,51,41,,
0x0070: 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c ,,,,,,,,,,,,,,,,
0x0080: 2c2c 2c2c 2c2c 3439 2c33 2e34 2c34 302c ,,,,,,49,3.4,40,
0x0090: 312c 342e 362c 3435 2c32 382e 372c 3430 1,4.6,45,28.7,40
0x00a0: 342c 2c32 2c30 2c30 2c30 2c32 382c 352c 4,,2,0,0,0,28,5,
0x00b0: 312e 302c 2c2c 2c2c 2c2c 2c2c 3438 2c34 1.0,,,,,,,,,48,4
0x00c0: 2e35 2c34 302c 322c 342e 362c 3434 2c32 .5,40,2,4.6,44,2
0x00d0: 382e 342c 3430 352c 2c32 2c30 2c30 2c30 8.4,405,,2,0,0,0
0x00e0: 2c32 382c 352c 312e 302c 2c2c 2c2c 2c2c ,28,5,1.0,,,,,,,
0x00f0: 2c2c 302c 302c 302c 3630 302c 3630 312c ,,0,0,0,600,601,
0x0100: 302c 302c 312c 312c 312c 312c 312c 312c 0,0,1,1,1,1,1,1,
0x0110: 312c 312c 312c 312c 312c 312c 312c 312c 1,1,1,1,1,1,1,1,
0x0120: 312c 312c 2d33 3134 392e 3531 3537 2c2b 1,1,-3149.5157,+
0x0130: 3131 3534 342e 3133 3039 2c33 372e 392c 11544.1309,37.9,
0x0140: 302e 312c 2032 2e33 2c20 322e 332c 2c2c 0.1,.2.3,.2.3,,,
0x0150: 4637 4646 4637 3030 3030 3030 3030 3030 F7FFF70000000000
0x0160: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000
0x0170: 3030 3030 3030 2c30 2e30 2c30 2e30 2c31 000000,0.0,0.0,1
0x0180: 2c20 3130 3832 382e 352c 2031 3131 3034 ,.10828.5,.11104
0x0190: 2e33 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c .3,,,,,,,,,,,,,,
0x01a0: 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c ,,,,,,,,,,,,,,,,
0x01b0: 2c2c 2c2c 2c2c 2c2c 2c2c 2c2a 3439 3335 ,,,,,,,,,,,*4935
0x01c0: 0d0a ..

08:58:59.252501 IP 192.168.0.47.53089 > 192.168.0.1.65501: UDP, length 423
0x0000: 4500 01c3 0000 4000 4011 b7a9 c0a8 002f E.....@.@....../
0x0010: c0a8 0001 cf61 ffdd 01af c7fc 2450 5f4d .....a......$P_M
0x0020: 412c 3337 352c 3235 352c 312c 3232 3031 A,375,255,1,2201
0x0030: 3236 3030 3537 3136 2c30 2c30 2c30 2c32 26005716,0,0,0,2
0x0040: 3230 3132 3630 3035 3731 362c 302c 302c 20126005716,0,0,
0x0050: 2c31 3030 2c31 3030 2c2c 2c2c 2c2c 2c2c ,100,100,,,,,,,,
0x0060: 2c2c 2c2c 2c2c 2c2c 2c35 312c 3431 2c2c ,,,,,,,,,51,41,,
0x0070: 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c ,,,,,,,,,,,,,,,,
0x0080: 2c2c 2c2c 2c2c 3439 2c33 2e34 2c34 302c ,,,,,,49,3.4,40,
0x0090: 312c 342e 362c 3435 2c32 382e 352c 3430 1,4.6,45,28.5,40
0x00a0: 342c 2c32 2c30 2c30 2c30 2c32 382c 352c 4,,2,0,0,0,28,5,
0x00b0: 312e 302c 2c2c 2c2c 2c2c 2c2c 3438 2c34 1.0,,,,,,,,,48,4
0x00c0: 2e35 2c34 302c 322c 342e 362c 3434 2c32 .5,40,2,4.6,44,2
0x00d0: 382e 352c 3430 352c 2c32 2c30 2c30 2c30 8.5,405,,2,0,0,0
0x00e0: 2c32 382c 352c 312e 302c 2c2c 2c2c 2c2c ,28,5,1.0,,,,,,,
0x00f0: 2c2c 302c 302c 302c 3630 302c 3630 302c ,,0,0,0,600,600,
0x0100: 302c 302c 312c 312c 312c 312c 312c 312c 0,0,1,1,1,1,1,1,
0x0110: 312c 312c 312c 312c 312c 312c 312c 312c 1,1,1,1,1,1,1,1,
0x0120: 312c 312c 2d33 3134 392e 3531 3537 2c2b 1,1,-3149.5157,+
0x0130: 3131 3534 342e 3133 3039 2c33 372e 392c 11544.1309,37.9,
0x0140: 302e 312c 2032 2e33 2c20 322e 332c 2c2c 0.1,.2.3,.2.3,,,
0x0150: 4637 4646 4637 3030 3030 3030 3030 3030 F7FFF70000000000
0x0160: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000
0x0170: 3030 3030 3030 2c30 2e30 2c30 2e30 2c31 000000,0.0,0.0,1
0x0180: 2c20 3130 3832 382e 352c 2031 3131 3034 ,.10828.5,.11104
0x0190: 2e33 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c .3,,,,,,,,,,,,,,
0x01a0: 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c 2c2c ,,,,,,,,,,,,,,,,
0x01b0: 2c2c 2c2c 2c2c 2c2c 2c2c 2c2a 3537 3933 ,,,,,,,,,,,*5793
0x01c0: 330d 0a 3..

Teppo Kurki

unread,
Jan 26, 2022, 12:57:33 AM1/26/22
to kplex
If you do know what all of that data is you could write a Signal K plugin to convert it to Signal K. Then the server could convert relevant items to NMEA 0183 and/or 2000 to be used elsewhere on your boat’s systems. Or write to a db for recall as graphs, that might come in handy with engine data.

Udp access from a plugin is easy, producing sk also, deciphering the data the hard part. Unless it is documented of course.

--
You received this message because you are subscribed to the Google Groups "kplex" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kplex+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kplex/6d705538-9437-4dc6-9c3d-a5c2f5759befn%40googlegroups.com.

Keith Young

unread,
Jan 26, 2022, 3:33:15 PM1/26/22
to kplex
kplex shuttles around NMEA sentences in fixed sized blocks.  Currently there's no way to accommodate the data above (and I have no idea what that bit after the trailing * is: it's not an NMEA checksum).  You could go down the signal K route Teppo describes.  I'm struggling to remember if the plugin capability I have in a branch could cope with those sort of data (I've not touched the code for some time) but you'd still be looking at reducing it down to something that would fit in an NMEA-sized sentence before multiplexing it (or having a plugin split it to multiple sentences).  As things stand right now Teppo's signal K solution is the one which would work for these data

Phil Wild

unread,
Jan 26, 2022, 9:11:23 PM1/26/22
to kplex
Thanks...
I know what the relevant fields are )but not all of them). I currently pull this data into Splunk to report on lots of things... I took photos of the LCD panel on the boat and then found the same data in the fields. Splunk can directly capture UDP but I'm trying to move away from Splunk and given it sort of looked like NMEA data, I thought I could use kplex to capture.

Now that I know it will never work, I just wrote a simple python script to capture the UDP and dump it into a log file.

Phil Wild

unread,
Jan 26, 2022, 9:27:15 PM1/26/22
to kplex
Thanks for your help. I also don't know what that last field is.
There was no documentation on this and the company would not assist.
I have identified the following fields (most are repeated for port/starboard engines):
date/time, fuel litres/hr, fuel_used, lat, lon, speed, direction, accelerator position, air intake pressure and temp, battery voltage, fuel litres/nm, engine oil pressure & temp, gearbox oil pressure & temp, engine hours, rpm, torque, engine water temp, total fuel consumed.

I track it all in Splunk with dashboards like the below...

BoatDashboard.jpg
Reply all
Reply to author
Forward
0 new messages