[fpc-pascal] MQTT package for freepascal/lazarus?
Bo Berglund
bo.berglund at gmail.com
Sun Oct 23 11:51:31 CEST 2022
On Sun, 23 Oct 2022 05:19:24 +0200, Jean SUZINEAU via fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:
>Le 22/10/2022 à 23:37, Bo Berglund via fpc-pascal a écrit :
>> If I could get at each output that mosquitto_cli writes into a script or such
>> then I would be good to go.
>Maybe with a redirection ( > ) to a file in bash ?
Do you mean something like this then:
Scriptfile checkmqtt:
#!/bin/bash
COMMFILE="$HOME/mqtt/messages"
eval "mosquitto_sub -h <ip of broker> -F '@Y- at m-@d @H:@M:@S ; %t ; %p' -t '#' >>
$COMMFILE"
And then an FPC program that essentially starts the script and then loops
checking for the existence of file $HOME/mqtt/messages and if found opens it and
processes each line of data and then erases the file?
Or even cleaner the FPC program could launch the command itself as a separate
process (in a thread maybe) and then loop as above checking for the output file
and so on?
Seems a bit roundabout but would use the existing working mosquitto program on
the Linux box to do the MQTT work...
I know that there will be about 5-10 seconds between each MQTT message arriving
so there is ample time to process each arrival.
TESTING.....
No it does not work!
The mosquitto output cannot be redirected like this because it seems to be
printed to an output screen which is not redirectable...
All that happens is that an empty file is created at start of the command and
then nothing more...
So how can one make mosquitto write output to a file instead?
--
Bo Berglund
Developer in Sweden
More information about the fpc-pascal
mailing list