Firmware Version from command line

General support for the Pi-Star System
Post Reply
User avatar
N7HHI
Posts: 41
Joined: Thu Apr 12, 2018 11:33 pm
Location: Wentzville, MO
Contact:

Firmware Version from command line

Post by N7HHI » Tue Feb 11, 2020 11:06 pm

I am trying to find the best way to display the firmware version form the command line.
The following snippet works after the system is up and running:

Code: Select all

grep 'MMDVM protocol version' /var/log/pi-star/MMDVM*.log | awk '{print $9}'
However, what I am trying to do is add the firmware version to the motd file at boot time. The log file in the above snippet is not present when rc.local is being run, so that code snippet produces an empty string when run at boot time.

Is there a better place to pull the firmware version from that exist at boot?
Last edited by N7HHI on Tue Feb 11, 2020 11:11 pm, edited 1 time in total.
73...
Scott - N7HHI

KE7FNS
Posts: 1035
Joined: Wed Apr 17, 2019 11:11 pm

Re: Firmware Version from command line

Post by KE7FNS » Wed Feb 12, 2020 11:03 pm

N7HHI wrote:
Tue Feb 11, 2020 11:06 pm
Is there a better place to pull the firmware version from that exist at boot?
Query the modem directly yourself, and mangle what it returns into the info you want.

Take a look at pistar-findmodem to see how it it is done, I doubt just using that script would work as it seems to now just hang and doesn't exit cleanly. It used to work, not sure when it started failing or why.

https://github.com/AndyTaylorTweet/Pi-S ... -findmodem
If someones previous actions are any indication of their future actions, then I predict the deletion and removal of access will happen at any moment. 7-11-2020.

"07/13/20 This Website Has Been Taken Down" ... again :lol:

User avatar
N7HHI
Posts: 41
Joined: Thu Apr 12, 2018 11:33 pm
Location: Wentzville, MO
Contact:

Re: Firmware Version from command line

Post by N7HHI » Thu Feb 13, 2020 7:03 pm

Thanks Jason,

At first glance I don't see what it would take from that script to get what I am looking for. When I get a chance I will investigate the script in more detail to see what I can get out of it.
73...
Scott - N7HHI

KE7FNS
Posts: 1035
Joined: Wed Apr 17, 2019 11:11 pm

Re: Firmware Version from command line

Post by KE7FNS » Thu Feb 13, 2020 8:34 pm

N7HHI wrote:
Thu Feb 13, 2020 7:03 pm
At first glance I don't see what it would take from that script to get what I am looking for.
You just send a packet of serial data to the serial port the modem is connected to and it spews out the result on the serial port.

https://github.com/AndyTaylorTweet/Pi-S ... dmodem#L46

The packet is simply 0xE0 0x03 0x00

0xE0 is the packet frame start message header. https://github.com/juribeparada/MMDVM_H ... rt.cpp#L27
0x03 = is the size of the packet
0x00 is the command. https://github.com/juribeparada/MMDVM_H ... rt.cpp#L29

https://github.com/juribeparada/MMDVM_H ... t.cpp#L202
If someones previous actions are any indication of their future actions, then I predict the deletion and removal of access will happen at any moment. 7-11-2020.

"07/13/20 This Website Has Been Taken Down" ... again :lol:

User avatar
N7HHI
Posts: 41
Joined: Thu Apr 12, 2018 11:33 pm
Location: Wentzville, MO
Contact:

Re: Firmware Version from command line

Post by N7HHI » Fri Feb 14, 2020 12:07 am

I ran the following to find the modem device:

Code: Select all

[email protected](rw):~$ find /dev/tty* ! -type l | grep -E "tty(AMA|ACM|USB|S)."
It resulted in:
/dev/ttyAMA0
/dev/ttyS0
/dev/ttySC0
/dev/ttySC1


I then tried the following with each of the devices from the results of the previous command:

Code: Select all

[email protected](rw):~$ sudo echo -en '\xE0\x03\x00' > /dev/ttyAMA0
Each device returned nothing. /dev/ttyS0 actually hung. I had to break out using a [Ctrl] C

This is probably user error on my part, not knowing exactly how to send a packet to the serial port. And I am not sure which device is the proper one. So I am probably in over my head...
73...
Scott - N7HHI

KE7FNS
Posts: 1035
Joined: Wed Apr 17, 2019 11:11 pm

Re: Firmware Version from command line

Post by KE7FNS » Fri Feb 14, 2020 3:19 am

N7HHI wrote:
Fri Feb 14, 2020 12:07 am
I ran the following to find the modem device:

Code: Select all

[email protected](rw):~$ find /dev/tty* ! -type l | grep -E "tty(AMA|ACM|USB|S)."
It resulted in:
/dev/ttyAMA0
/dev/ttyS0
/dev/ttySC0
/dev/ttySC1
While the above code would work, there really isn't a reason to use it since your hotspot is already setup and configured. I would just snag the port from the MMDMVHost configuration instead.

Code: Select all

grep Port=/dev /etc/mmdvmhost
the P in Port needs to be capitalized.
N7HHI wrote:
Fri Feb 14, 2020 12:07 am
I then tried the following with each of the devices from the results of the previous command:

Code: Select all

[email protected](rw):~$ sudo echo -en '\xE0\x03\x00' > /dev/ttyAMA0
Each device returned nothing. /dev/ttyS0 actually hung. I had to break out using a [Ctrl] C

This is probably user error on my part, not knowing exactly how to send a packet to the serial port. And I am not sure which device is the proper one. So I am probably in over my head...
My guess as to why it didn't work for you is you didn't stop MMDVMHost. You are running into a conflict by trying to use a serial port that is currently in use by MMDVMHost.

Make sure MMDVMHost is stopped before you try to query the modem.

The find modem script clearly does all of this step by step, so study it a bit more, and copy it and perform the same steps in the same order in your script.
https://github.com/AndyTaylorTweet/Pi-S ... dmodem#L21

Code: Select all

sudo systemctl stop mmdvmhost
It seems that your goal might be a tad too difficult for you to achieve currently, so if this is just for your personal hotspot you don't really need a realtime result from the modem, just fake it and manually add the text you want to be displayed in the MOTD and be done with it.

Or... another way to cheat it would be to set the drive to RW and write the correct results of your initial post into a file in the home dir, and then when your MOTD is built just snag the info from the file you wrote, and not the log that doesn't exist. You seem to be narrowed in on the tempfs and forgetting that you have an entire drive where you can store information and it will remain persistent after reboots.
If someones previous actions are any indication of their future actions, then I predict the deletion and removal of access will happen at any moment. 7-11-2020.

"07/13/20 This Website Has Been Taken Down" ... again :lol:

Post Reply