Teltonika ModemPCI/G10 under FreeBSD
From MyWiki
I needed an SMS modem under FreeBSD 7-stable, so I looked around and found Teltonika modems that come in PCI, USB and serial versions. I saw that someone was able to run USB model with uftdi driver, but nothing about PCI model. So, I asked Mykolas from Teltonika and he confirmed that all three based on the same chipset, but they have not tested it under FreeBSD. But he kindly sent me Linux configuration instructions and I took it from there.
So, I bought two modems USB and PCI one and went to work :-)
USB was easy. All I needed to add to my kernel configuration was:
device uftdi device ucom
The modem was detected without a problem. But that didn't help with PCI one. Reading the manual revealed that I need the following two lines in my kernel configuration file:
device puc options COM_MULTIPORT
The last one was an educated guess after reading the Linux pdf file that Mykolas sent me and my prior experience of setting up Huawei modem under Linux. Since I was getting two extra serial ports COM_MULTIPORT was a logical thing to add. Besides, I came across a post that the option adds stability to serial multiport cards, so why not try? :-)
I added the lines and rebuilt kernel. Reboot, but no extra serial ports. But I can see the card there with lspci:
01:06.0 Serial controller: NetMos Technology PCI 9820 Multi-I/O Controller (rev 01) (prog-if 02 [16550]) Subsystem: LSI Logic / Symbios Logic Device 0001 Flags: medium devsel, IRQ 10 I/O ports at dc00 I/O ports at d880 I/O ports at d800 I/O ports at d480 I/O ports at d400 I/O ports at d080
Back to reading man puc and here it comes right into my face:
The list of supported devices is in sys/dev/puc/pucdata.c. Support for new cards should be added there.
Examining /usr/src/sys/dev/puc/pucdata.c revealed that I need details to populate the following structure from /usr/src/sys/dev/puc/pucdata.h:
struct puc_cfg { uint16_t vendor; uint16_t device; uint16_t subvendor; uint16_t subdevice; const char *desc; int clock; int8_t ports; int8_t rid; /* Rid of first port */ int8_t d_rid; /* Delta rid of next ports */ int8_t d_ofs; /* Delta offset of next ports */ puc_config_f *config_function; };
So, I run lspci once again with -vn option to get numbers instead names from vendor, device, etc.:
01:06.0 0700: 9710:9820 (rev 01) (prog-if 02 [16550])
Subsystem: 1000:0001 Flags: medium devsel, IRQ 10 I/O ports at dc00 I/O ports at d880 I/O ports at d800 I/O ports at d480 I/O ports at d400 I/O ports at d080
After comparing the above to what was already in /usr/src/sys/dev/puc/pucdata.c, I came up with the following lines for Teltonika ModemPCI/G10:
{ 0x9710, 0x9820, 0x1000, 1, "NetMos NM9820 Multi-I/O controller", DEFAULT_RCLK, PUC_PORT_2S, 0x10, 4, 0, },
Added the lines to /usr/src/sys/dev/puc/pucdata.c, rebuilt the kernel and it worked! :-) After reboot I had the following in my /var/run/dmesg.boot:
puc0: <NetMos NM9820 Multi-I/O controller> port 0xdc00-0xdc07,0xd880-0xd887,0xd800-0xd807,0xd480-0xd487,0xd400-0xd407,0xd080-0xd08f irq 10 at device 6.0 on pci1 puc0: [FILTER] uart0: <Non-standard ns8250 class UART with FIFOs> on puc0 uart0: [FILTER] uart1: <Non-standard ns8250 class UART with FIFOs> on puc0 uart1: [FILTER]
And I had two new serial ports to work with /dev/cuau0 and /dev/cuau1. I couldn't wait to try it now :-). Took SIM card from one of my mobile phones and using instructions from SMS Tutorial I tried to send SMS to myself:
# cu -l/dev/cuau0 -s115200 Connected AT OK AT+CPIN="0616" OK AT+CMFG=1 OK AT+CMGW="+35386XXXXXXX" >Hello from Teltonika, Alex! +CMGW: 1 OK AT+CMSS=1 +CMSS: 7 OK
And a second later I had the inbound SMS on my mobile :-) (Note: "+35386XXXXXXX" in the above is obfuscated mobile number and "0616" is not really my PIN, but you get the idea how to enter it).
Now I can add SMS notification to my email one in Nagios. :-)