[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Sending NMEA to other device from my APP via Serial
From: |
Bo Berglund |
Subject: |
Re: Sending NMEA to other device from my APP via Serial |
Date: |
Sun, 17 Mar 2024 15:30:04 +0100 |
On Sat, 16 Mar 2024 19:42:50 +0000, Hans Kurscheidt <lve0200@gmail.com> wrote:
>Hi there,
>just assume Raspberry Pi under Linux Debian and ublox GPS via USB.
>I'm running gpsd in my APP, using the shared mem i/f under C++.
>All fine! But there's another device which I have to feed w/ NMEA
>from my RPI via RS232/V.24.
>Can't get my head around, what would be the easiest way, doing it.
>Off course, I would prefer just piping NMEA sentences directly from
>the device to one of my /dev/tty devices. Any suggestion?
>Thank you in advance.
>hk
I would do the following:
1) Install an MQTT broker on a device on the network (could be on your RPi GPS
reader device itself or another RPi).
sudo apt install mosquitto mosquitto-clients
Then configure the server to allow external cnnections:
sudo nano /etc/mosquitto/conf.d/mosquitto.conf
Add these lines:
allow_anonymous true
listener 1883
Then restart the service:
sudo systemctl restart mosquitto
2) In your GPS reader software extract each GPS telegram separately and post it
as text to the MQTT broker.
In a temperature sensor reading script I use this is how I send the data to
MQTT:
MQTTIP=<IP address of MQTT broker machine>
CurrTempA=<the temperature value to post>
eval "mosquitto_pub -h ${MQTTIP} -t \"sensors/outdoor/temp\" -m \"$CurrTempA\""
3) On the receiving end the client will subscribe to the topic
"sensors/outdoor/temp" and read the received data.
This is how I log MQTT messages in another script:
FULLOG="${LOGDIR}/${LOGFILE}"
MQTTID="UBU-$RANDOM"
#Subscribe to message stream and log to file (blocking call):
eval "mosquitto_sub -h ${MQTTIP} -i $MQTTID -F '@Y-@m-@d @H:@M:@S ; %t ; %p' -t
'#' >> ${FULLOG}"
So this script is started and then it writes all received messages to the log
file until killed. So my script is blocking and actuallly started in crontab on
boot.
Obviously you will have to do something else in your handler but that is up to
you....
HTH
--
Bo Berglund
Developer in Sweden