Send SMS msg via Serial port to GSM Modem

Hello,
Is anybody has the experience or sample code to send an SMS message via AT Command via the serial module to GSM Modem?

The AirLink® LS300 is an expensive deivce for some small projects and clients only want simple alarm SMS handling.

Well… I don’t have any sample code, but a long long time ago when we were writing the SMS notification stuff we started with serial devices and AT commands. I can tell you it’s not very difficult, but it’s something best done in Java code by a module, especially if you need it to be used with the alarm system.

We went with the airlink because we found these serial modems to be pretty unreliable and even when they were working the throughput (think SMS per second) was very slow.

1 Like

Because I don’t know JAVA it is easy for me to write it in Python with the serial module but my problem is the return packet of the modem is not end with any delimiters and the length is dynamic so I can’t use system.serial.readUntil or system.serial.readBytes when waiting for a response from the modem.

We must have a function that returns packets when there are no activities after some 2 or 3 times of a bit rate of configured serial buad rate. This is common method then I use a serial port in microcontroller.

So I just need some help base on that.

About 8 years ago I remember I made a small PLC program using Micrologix 1400 with a Teltonika router, pushing ASCII strings over serial to provide AT commands, just to prove the AB rep I do not need their fancy, expensive and clunky modem. Never used it though. Anyway if it is doable with a MLX1400 with Ignition I think must be easier.
If in two weeks you are in same spot I will try to take a look to the serial module.

Thanks @allnet yes I did some AT commands code before but I like I said I wonder how to detect packet when there is no delimitator or fixed packet size

Timeouts. This has to be configured in an Ethernet-Serial converter, too, if you use one. (The “force transmit” setting in Moxa devices, for example.) You generally need a dedicated thread in Ignition, with all of the life cycle hassles that entails.

The approach is to use a long timeout to read one byte while looking for the start of a packet, checking for interruption at each return. When a byte is read, stick it in a buffer and start an inner loop with minimal timeouts for the number of bytes the port says are available (but not less than one), adding received bytes to the buffer as you go. When you get nothing on the short timeout, deliver the buffered bytes and return to the outer loop. Also checking for interruption in the inner loop.

1 Like