byGary Roberts| Updated: 12/09/2015 | Comments: 1
Have you ever wanted the ability to control your Raven cellular modem with your data logger? Would it be nice to be able to get data on the health of your cellular modem and its data network? Maybe you even want to reset your Raven modem. What if I told you that it’s quite easy to do all of this using the CRBasic programming language? In this article, I’ll share with you the experience I had trying this out and show you how you can do it too.
在为客户做一些研究时,我遇到了乌鸦XT手册中的一些有趣信息。手册表示,乌鸦调制解调器可以通过TCP / IP的终端程序在命令中驱动。这些AT命令是用于控制,拨号和配置调制解调器的一组指令。
推荐的佛r You:You can find AT commands listed in the“Supported AT Command Reference” document from Sierra Wireless。有关使用其设置的AT命令的更新列表,请检查Sierra Wireless提供的Web管理界面是否为调制解调器。 |
Based on this information, I decided to try using these commands in LoggerNet’s Device Configuration Utility (DevConfig) to check the current modem settings, change the settings, and direct the modem to do various activities.
Here are the steps I took if you want to try this too:
By following these steps, I knew that I could get valuable, real-time information from my modem. If it worked doing it by hand using a terminal program, surely a CRBasic data logger could get the same data, as well as store the data for me for later use and analysis, right?
对于我的CRBasic数据记录器使用TCP / IP将“Talk”进行“谈话”,因为我的终端程序所做的,我需要同时配置调制解调器和数据记录器,用于指向点协议(PPP)。为此,请按照乌鸦调制解调器手册中的说明进行操作。您可以在附录中找到用于配置PPP的调制解调器的说明。
我开始撰写我的Crbasic计划,因为我通常会。我使用了CRBasic编辑器生成的基本模板,并添加了一组变量以存储调制解调器信息(包括RSSI)。
Note:您使用的调制解调器可能具有可以查询的更多或不同的变量,但下面的列表显示了我想跟踪的变量。
'公共变量用于存储从raven调制解调器公共current_day_usage收到的信息,因为longers_day_usage = kb public current_month_usage作为长单元current_month_usage = kb public current_week_usage作为longle onlult_week_usage = kb publicnetwork_operator作为字符串公共网络_service_type作为字符串公共网络_state作为字符串*50 public publet_day_usage as long sonegard_day_usage = kb public publet_usage作为long soneg _month_usage = kb public publet_usage作为long overs_week_usage = kb public rap_device_time作为字符串public rap_device_port作为字符串public raven_ip_address作为字符串dim duen_ip_address作为string publicRaven_phone_number作为字符串公共rap_mac_address作为字符串public rap_modem_name作为字符串public rap_serial_port_configuration作为字符串public raven_serial_port_mode作为字符串公共raven_voltage单位raven_voltage = volTS Public RSSI.
返回调制解调器的数据后,您需要通过它解析。要保存解析信息,您需要创建一些临时字符串变量和TCP / IP套接字。这就是我的方式:
公共套接字(2)作为长公共单元_on_usage_data作为字符串的变量,用于解析raven调制解调器返回的字符串。const crlf = chr(13)&chr(10)dim return_value作为string * 70'temp字符串,以保持调制解调器dim string_location返回的值
在我的程序的慢速序列扫描之一中,我在乌鸦调制解调器上打开了一个TCP / IP套接字到端口2332。你可以使用这个TCPOpen()instruction in CRBasic to connect to your Raven modem’s internal (behind its firewall) default TCP/IP address of 192.168.13.31. This creates a comport parameter that you can use later in the program, instead of specifying a communications port.
Tip:Use theTCPOpen()以在出现问题的情况下以缓慢序列指令,并且连接失败。这样,您的其他临界测量不会被举行。
socket(1) = TCPOpen("192.168.13.31", 2332, 100)
在我知道我有一个很好的套接字连接之后(即,套接字报告的值大于100),我试图登录调制解调器的终端。你可以使用这个SerialOut()instruction with the TCP/IP socket that you just created as the comport parameter.
If(socket(1) > 0) Then SerialOut(socket(1), "" , "Password", 1, 200) 'Wait for the Password prompt before sending the password.
The data logger waits for the word “Password” before it moves on to the next instruction (or it times out).
SerialOut(socket(1), "12345" & CRLF, "OK", 1, 200) 'Send the password and wait for the OK to move on.
After the data logger successfully “sees” the word “Password,” it sends the password “12345” followed by a carriage return and a line feed (the equivalent of you clicking theEnterbutton on your keyboard). The data logger then waits for “OK” before moving to the next CRBasic instruction.
You can use theSerialFlush()instruction to clear out your data logger’s serial buffer. (I did this so that I knew that I was working with a clean buffer, clear of surprises that could mess up my running CRBasic code.) The data logger then sends the “AT*NETRSSI?” AT command to the modem (followed by a carriage return and line feed)—just like when you used your terminal program in DevConfig.
SerialFlush(socket(1)) SerialOut(socket(1), "AT*NETRSSI?" & CRLF, CRLF, 1, 200) 'Query for Signal Strength (RSSI).
The data logger then looks at the string returned to it by the modem, searching for the first carriage return and line feed. After the data logger has the location of the carriage return and line feed in the string “returned_value,” it uses this location to copy everything in front of the carriage return and line feed to the “rssi” variable, which is also a string.
SerialIn(returned_value, socket(1), 100, 0, 1000) string_location = InStr(1, returned_value, CRLF, 2) rssi = Mid(returned_value, 1, string_location - 1)
您的数据记录器现在具有您的Raven调制解调器的当前RSSI值,可以存储此信息,操作它,将其电子邮件发送给您等等。非常容易从调制解调器获取信息,不是吗?
When you’re finished getting the data that you need, you can use thetcpclose()将数据记录器关闭IP套接字的指令将IP套管关闭到您的Raven调制解调器。
TCPClose(socket(1))
Now that you’ve used your data logger to get data from your modem, you’re ready to learn how to manipulate and control your modem. In the code example below, you can see how to reset or restart your modem every hour at the top of the hour. The data logger then goes through the same login process that it did in the example we just went through. When it has successfully logged in, it sends the AT command “ATZ” to the modem.
If(IfTime(0, 1, hr)) Then socket(2) = TCPOpen("192.168.13.31", 2332, 100) SerialOut(socket(2), "" , "Password", 1, 200) 'Wait for the Password prompt before sending the password. SerialOut(socket(2), "12345" & CRLF, "OK", 1, 200) 'Send the password and wait for the OK to move on. If(socket(2) > 0) Then SerialFlush(socket) SerialOut(socket, "ATZ" & CRLF, CRLF, 1, 200) 'Reset/reboot the raven modem EndIf If(TCPClose(socket(2)) = 2) Then socket(2) = -1 EndIf
Tip:重新启动是一个很好的命令在您的程序中拥有,因为有时时代的调制解调器连接到蜂窝网络变得陈旧。重启刷新所有内容并再次获取此工作。
For a full example of this program, which includes getting other data items from a Raven modem, download theraven-status.dld文件。
I hope you found this information useful. If you have any questions, clarifications, or enhancements, please post them below.
Comments
lucas z.|05/30/2018 at 01:07 PM
您好,我意识到这篇文章现在已经几年了,但我想使用类似的代码通过DataLogger上的RS-232端口(串行)而不是IP连接通信。我想通过记录器编写每天发送此信息并重置调制解调器。您是否可以提供任何关于配置序列转移和延迟时间的指导?我没有的代码似乎在这个时候工作。谢谢你的帮助!
Pleaselog in or registerto comment.