I am developing a smart agriculture application on a Raspberry Pi 3 B+ (Buster). For cellular comms I use a Nova SARA-R410M-02B modems with a Hologram SIM card.
Also part of the application is an XBee RF radio that receives sensor data from the field. Both devices use serial IO via the Pi USB ports.
My application is written in Ruby and uses the Serialport gem for serial communications. I set up a udev rule that creates a symlink called ttyNOVA for the Nova modem and ttyXBEE for the SBee radio:
SUBSYSTEM==āttyā, ATTRS{idVendor}==ā05c6ā, ATTRS{idProduct}==ā90b2ā, KERNEL==āttyUSB*ā, SYMLINK+=āttyNOVAā, MODE=ā0666ā
SUBSYSTEM==āttyā, ATTRS{idVendor}==ā0403ā, ATTRS{idProduct}==ā6015ā, KERNEL==āttyUSB*ā, SYMLINK+=āttyXBEEā, MODE=ā0666ā
When the Pi boots up everything is set up ok:
lrwxrwxrwx 1 root root 7 Mar 5 08:45 ttyNOVA ā ttyUSB2
lrwxrwxrwx 1 root root 7 Mar 5 08:45 ttyXBEE ā ttyUSB0
After opening the serial port for ttyNOVA the port functions normally with:
cell port signals = {ārtsā=>1, ādtrā=>1, āctsā=>1, ādsrā=>0, ādcdā=>0, āriā=>0} (Note that āctsā=>1)
After starting the application everything hums along until the serial port is suddenly lost. Might take a few minutes or many hours.
Grepping the syslog for entries with āusbā in them I find a pattern like this:
Mar 2 14:52:38 raspberrypi kernel: [ 131.566043] usb 1-1.3: USB disconnect, device number 8
Mar 2 14:52:38 raspberrypi kernel: [ 131.568025] qmi_wwan 1-1.3:1.3 wwan0: unregister āqmi_wwanā usb-3f980000.usb-1.3, WWAN/QMI device
Mar 2 14:52:39 raspberrypi kernel: [ 132.632517] usb 1-1.3: new high-speed USB device number 9 using dwc_otg
Mar 2 14:52:39 raspberrypi kernel: [ 132.763246] usb 1-1.3: New USB device found, idVendor=05c6, idProduct=90b2, bcdDevice= 0.00
Mar 2 14:52:39 raspberrypi kernel: [ 132.763263] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Mar 2 14:52:39 raspberrypi kernel: [ 132.763273] usb 1-1.3: Product: QHSUSB__BULK
Mar 2 14:52:39 raspberrypi kernel: [ 132.763282] usb 1-1.3: Manufacturer: Qualcomm CDMA Technologies MSM
Mar 2 14:52:39 raspberrypi kernel: [ 132.763291] usb 1-1.3: SerialNumber: db4cad1d
Mar 2 14:52:39 raspberrypi kernel: [ 132.764775] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB1
Mar 2 14:52:39 raspberrypi mtp-probe: checking bus 1, device 9: ā/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3ā
Mar 2 14:52:39 raspberrypi mtp-probe: checking bus 1, device 9: ā/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3ā
There is no other USB activty in the syslog around this time. Any idea what might be causing this? XBee port āinterferenceā?
After this, the next time the Nova serial port is accessed (eg. to = serialport.read_timeout) an exception is thrown:
Input/output error - tcgetattr on port /dev/ttyNOVA
As far as I can tell, this error implies that the serial port no longer exists, or is in some way invalid.
This makes sense as ttyNOVA is now linked to a disconnected port (ttyUSB2) but reconnected to another port (ttyUSB1).
Currently, the application is designed to shutdown and restart at this point (sudo shutdown -r now).
Often, it comes up and there are two immediate observations.
First, after opening the ttyNOVA port we get:
cell port signals = {ārtsā=>1, ādtrā=>1, āctsā=>0, ādsrā=>0, ādcdā=>0, āriā=>0} (Note that āctsā=>1)
Note that āctsā=>0. Whenever this happens it indicates the serial port is not properly initialized.
No AT commands execute successfully. Bytes appear to be written but usually there is no valid response.
Sometimes there is a āresponseā of sorts, but it is nonsense. For example, often I will see a byte pattern something like
1, 0, 0, 0, 48, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 4, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
This response has 48 bytes, but sometimes there are hundreds.
Second, before issuing the first AT command (ATE0) the input buffer is cleared. Invariably if there are characters in the buffer, they are always the same:
0x60 0x0a 0x00 0x9e 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xef 0xad 0x7e
followed by a ānilā. Anyone recognize this byte pattern (I donāt)?
Usually after a few restarts, things return to normal and communications are restored.
I should also note that I have three test systems running atm and only one is exhibiting this poor behaviour. Also, the problem modem has had the latest firmware upgrade installed (https://support.hologram.io/hc/en-us/articles/360035212594-Updating-the-Cat-M1-R410-Nova-s-Firmware).