Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

CR1000 data sending over GPRS


macarli Jan 19, 2011 10:29 AM

Hi all,

We have CR1000 base remote station(with telit EZ-10 GPRS Modem) which communicates to central PC over GPRS Modem. We want this station to send necessary data every hour to the central PC, whose IP and port numbers are known, over GPRS. We do not want Loggernet to take these data. Our own software/FTP server will listen this port and when data come, it will write these data to the database. Moreover we want time synchronization from the NTP server over this central PC.
How can we do these? what procedure do we have to follow?

Thanks for your help

Macar


Sam Jan 19, 2011 06:45 PM

Macar,

We have customers do this regularly. They generally take one of the following approaches. Any particular reason you're deciding not use LoggerNet? LoggerNet does support "callback" from loggers and would be very easy to implement in the logger coding wise.

1) Write data using TableFile instruction, then FTP the file to their server

3) Write data using TableFile instruction, then Email the file to their server. Very similar process as (1)

5) Use GetRecord, TCPOpen, and SerialOut to extract data table records and push them out an IP socket.

-----------------------------------------------------
An example of (1) can be found in this thread

http://www.campbellsci.com/forum/messages.cfm?threadid=5FF6008B-013F-673B-CF27BDC1BBC4FFB0

-----------------------------------------------------
Following is an example of (3)

' Operational Notes:
' * Record sending is based on record number and not timestamps
PreserveVariables
Public PTemp, batt_volt
'Network Settings and Variables
Public DataServ As String * 15 = "192.168.13.10" 'address of server listening for data
Public DataServPort As Long = 6000 'port on server listening for data
Public DataServSock 'will hold socket assignment on logger
Public DataHold As Boolean = FALSE 'flag for pausing data sending
Dim DataRecover As Boolean 'flag for data recovery mode
Public Rec As Long 'last record number in data table
Public LRecSent As Long = -1 'last record we tried to send
Public RecBack As Long 'number of records still need to send
Const GRDataMaxLen = 127 'max length of GRData string
Public GRData As String * GRDataMaxLen 'string for holding record data

Public NTPServ As String * 31 = "192.168.13.10" 'address of NTP server
Public GMTOffset = -6 'hours
Public NTPErr 'milliseconds
Public SyncTime As Boolean = FALSE 'flag for forcing network time syncing

DataTable (Min15,1,-1)
DataInterval (0,15,Min,10)
Sample (1,batt_volt,FP2)
Sample (1,PTemp,FP2)
EndTable

DataTable (ComsLog,1,100)
Sample (1,DataServSock,FP2)
Sample (1,Rec,FP2)
Sample (1,LRecSent,FP2)
Sample (1,RecBack,FP2)
Sample (1,GRData,String)
EndTable

BeginProg
Scan (15,Min,0,0)
PanelTemp (PTemp,250)
Battery (batt_volt)
CallTable Min15
NextScan

SlowSequence
Do While TRUE 'inifinite loop
'Get number of last record in table
'Determine how far back need to go to catch up
'Rec = Min15.Record 'get number of last record in table
If Rec < LRecSent Then LRecSent = -1 'What if LRecSent is preserved but datatable has been reset? Reset LRecSent.
RecBack = Rec - LRecSent 'determine how much need to catch up
If NOT DataHold Then 'not holding sending of data
If RecBack > 0 Then 'If recback is greater than zero then we have records to send
If DataServSock >= 100 Then 'successfully opened socket to server
LRecSent = Rec - RecBack + 1 'calc new last record number sent
GetRecord (GRData,Min15,RecBack) 'extract data from data table
'Form string for sending: "YYYY-MM-DD HH:MM:SS", RECNUM, DATA, DATA, DATA
' "2010-05-24 17:09:30",70,13.33,23.64
GRData = Left (GRData,InStr (2,GRData,"""",2)) & "," & LRecSent & Mid (GRData,InStr (2,GRData,"""",2) + 1,1000) & CHR(13)
SerialOut (DataServSock,GRData,"",0,0) 'send data out over socket
CallTable (ComsLog)
EndIf 'socket
EndIf 'recback
DataServSock = TCPOpen (DataServ,DataServPort, GRDataMaxLen * 100) 'attempt to create link with data server
EndIf 'datahold
Loop
EndSequence

SlowSequence
Scan (5,Sec,3,0)
If TimeIntoInterval (0,24,Hr) OR SyncTime Then
SyncTime = FALSE
'Network Time Sync'ing
NTPErr = NetworkTimeProtocol (NTPServ,GMTOffset * 3600,1000)
EndIf
NextScan
EndSequence
EndProg


macarli Jan 20, 2011 01:08 PM

Hi Sami


Thanks for your detailed answer.

The reason why we do not use loggernet is; in the second part of our project we want to monitor wind speed and direction data of the remote stations(approximately 10 station) almost online(1 data from all stations for every 15 seconds). By using loggernet for one station, this can be done for 1 data in 1 minute. Moreover when the remote station numbers increase this time will increase.

So we planned to use IP socket and every remote station will connect to the same computer with different port numbers and send its data every 15 seconds. And our software will listen these ports and get the data and write to the database.
Can this be possible?

Thanks
Macar


Sam Jan 20, 2011 03:07 PM

Macar,

I do not know why it is taking 1 minute to collect one data record from your stations. That is way too long. However, we have already developed a variety of solutions for applications just like yours. The bonus is that you don't have to re-invent the wheel and we have already done the testing!

-------------------------------------
LoggerNet Initiating Communication and Data Collection:
1) Assign "IPPort" root for every remote.
2) Place "PakBusPort" under the "IPPort" - Check "PakBus Port Always Open" - LoggerNet will keep communications open with the remote so that communications do not have to be established every 15 seconds for data transfer.
3) Add you logger under the PakBusPort and set scheduled collection interval to 15 seconds.

-------------------------------------
Logger Initiating Communication, LoggerNet Initiating Data Collection:
(This can also be done using IPPort and unique ports for callback)
1) Assign "IPPort" root for every remote
2) Give each IPPort root
2) Place "PakBusPort" under the "IPPort" - Check "PakBus Port Always Open" - LoggerNet will keep communications open with the remote so that communications do not have to be established every 15 seconds for data transfer.
3) Add you logger under the PakBusPort and set scheduled collection interval to 15 seconds.

1) Add a "PakBusTcpServer" Root to Setup
2) Add your Loggers under the PakBusTcpServer
3) Check PakBus Port Always Open
4) Add the PakBus address ranges that should be maintained
5) Set scheduled collection interval to 15 seconds.
6) Using Device Configuration Utility -> Net Services -> PakBus/TCP Client Connections, enter the address and port number of the LoggerNet server

-------------------------------------
Logger Initiating Communication, Logger Initiating Data Collection
1) Use IPPort (with callback enabled) or PakBusTcpServer root - which one to used depends on if all stations need to share a single IP port for callback.
2)


Sam Jan 20, 2011 03:15 PM

Macar,

I do not know why it is taking 1 minute to collect one data record from your stations. That is way too long. However, we have already developed a variety of solutions for applications just like yours. The bonus is that you don't have to re-invent the wheel and we have already done the testing!

-------------------------------------
LoggerNet Initiating Communication and Data Collection:
1) Assign "IPPort" root for every remote.
2) Place "PakBusPort" under the "IPPort" - Check "PakBus Port Always Open" - LoggerNet will keep communications open with the remote so that communications do not have to be established every 15 seconds for data transfer.
3) Add you logger under the PakBusPort and set scheduled collection interval to 15 seconds.

-------------------------------------
Logger Initiating Communication, LoggerNet Initiating Data Collection:

(This can also be done using IPPort and unique ports for callback)
1) Assign "IPPort" root for every remote
2) Set Callback enabled for each IPPort
3) Assign a unique IP Port used for call back for each IPPort root (if you need a shared port, see PakBusTcpServer")
4) Place "PakBusPort" under the "IPPort" - Check "PakBus Port Always Open" - LoggerNet will keep communications open with the remote so that communications do not have to be established every 15 seconds for data transfer.
5) Add you logger under the PakBusPort and set scheduled collection interval to 15 seconds.
6) Using Device Configuration Utility -> Net Services -> PakBus/TCP Client Connections, enter the address and port number of the LoggerNet server

-------------------------------------
Logger Initiating Communication, Logger Pushing Data or Initiating Data Collection

1) See steps 1 - 4 above
2) Use CRBasic to program the logger to open a connection with the LoggerNet server - See the "TCPOpen" instruction

3a) Use the socket result from "TCPOpen" as the ComPort for the "SendData" instruction. This will push data to the server.

3b)Use the socket result from "TCPOpen" as the ComPort for the "SendVariables" instruction. Set "TableName" = "Public", "FieldName" = "callback", "Variable" = 1, and "Swath" = 1. The logger will is basically saying, "Hey I'm calling back, collect my data now".

To discuss this further, definitely call in to our support line and ask for Sam or Software Support.


macarli Jan 21, 2011 02:45 PM

Hi Sam,
Thanks for your answer again. These approaches are reasonable for us. However i cant make the link (i am new in CRBasic:( ).
I have some questions;

1. In the first approach, do i have to use dynamic IP?
2. I think second approach is most suitable for us. I tried this but i cant make the link. In fact I do not understand what must i do in logger side. Moreover what should i write to the "internet IP address" in the loggernet IPport. Can you please tell these detailed and any example?

thanks
Macar


Sam Jan 21, 2011 03:26 PM

Macar,
First I will say that I know little about GPRS modems and the examples given are generalized for a logger with an IP connection, however that be made (e.g. NL120, Cellular modem).

Regarding (1), the remote logger must accessible via a known IP address or hostname. Additionally, the port used for PakBus communications must be known. That information will be used to populate the "Internet IP Address" field of the "IPPort" root in LoggerNet's Setup. Here ares some examples: 555.555.555.555:6785 or my.logger.com:6785.


Regarding (2), the "Internet IP Address" field of the "IPPort" root in LoggerNet's Setup will be left blank. That's right, blank. One of the advantages of (2) is that the IP address of the remote does not need to be known because the logger is calling home. The logger knows where the LoggerNet server is located (static IP) and initiates communications. However, it is very important that you populate the "IP Port Used for Call-Back" field and check the "Call-Back Enabled" box. Subsequently, you need to make your LoggerNet Server and that call-back port accessible to the outside world so your remote logger can successfully connect. Then using Device Configuration Utility -> Net Services -> PakBus/TCP Client Connections, enter the address and port number of the LoggerNet server.

On my desk, I did the following:

1) Add IPPort Root
Internet IP Address = (cleared) ":6785"
Call-Back Enabled = CHECKED
Cache IP Address = CHECKED
IP Port Used For Call-Back = "6785"

2) PakBusPort (under IPPort)
Communication Enabled = CHECKED
PakBus Port Always Open = CHECKED

3) CR1000 (under PakBusPort)
Communications Enabled = CHECKED
Call-Back Enabled = CHECKED
PakBus Address = (*UNIQUE* PakBus address of the Remote) 10
Scheduled Collection Enabled = CHECKED
Collection Interval = 15s
Data Tables of Interest Included For Scheduled Collection

4) Opened my firewall to forward inbound traffic on port 6785 to port 6785 of my LoggerNet server computer

5) On remote CR1000 logger,
Device Configuration Utility -> Net Services -> PakBus/TCP Client Connections
Entered the address and port number of my LoggerNet server

6) Waited until logger established communications with LoggerNet server. This can take several minutes after a power cycle, but all the data will be collected when coms are established. I know it has called back by watching the Log Tool output and also by seeing that "Internet IP Address" was automatically populated for me when the logger connected in.

7) When I added additional loggers, I repeated steps 1-6, but I used a unique PakBus address for the new remotes and a unique Port for call back.

* Last updated by: Sam on 1/21/2011 @ 8:28 AM *


macarli Jan 25, 2011 04:38 PM

Sam,

Do i have to use Raven Modems for IPport communication? Because i cant connect the CR1000 to IPport by using EZ-10 GPRS modem. I think AT commands and PPP settings are diffrent.
Any idea?


Sam Jan 26, 2011 03:43 PM

No. You do not have to use the Raven. However, you will want to configure the EZ-10 to support PPP communications with the logger. That will require understanding the sequence of AT+ commands required to configure the modem.


macarli Jan 27, 2011 10:11 AM

When i tried by connecting the CR1000 to the hyperterminal, i see my problem is similar to the thread "http://www.campbellsci.com/forum/messages.cfm?threadid=0EEE806B-07C3-0D3D-B1FC4391399F8B45".

As like there, I always see "AAAAAAA+++AAAAAAA" string. CR1000 waits an echo from the terminal, so when i press "A" then it goes on process as in my modem dial string. However for my modem(supports Hayes Modem Protocol), it echo back when "AT" comes. So modem never echo to the CR1000 since "A" and "T" donot come together. So, CR1000 goes on sending "AAAAA"s and modem always wait.

Do i made something wrong or how can i overcome this problem?


Sam Jan 27, 2011 03:05 PM

Macarli,

It sounds like the modem is not following standard Hayes modem protocol (not echoing back after the A).

I suppose you have a couple of options:

1)As Andrew indicated in the post you referenced:

If all else fails set the CGDCONT setting in the modem using hyperterminal (as you have done). Most modems will remember this setting through power cycles etc. If this works then you can just use the second command alone.
Make sure the connect response you enter matches that the modem sends on connection. "CONNECT" will do if the modem is set in verbose mode, if in numeric mode, the response can vary.

2) You could use the SerialI/O commands in CRBasic to send the AT configuration commands.
This document will be a big help.
http://www.campbellsci.com/documents/technical-papers/serial.pdf
I know it references "Serial Sensors" in the title, but the same principles apply.

* Last updated by: Sam on 1/27/2011 @ 8:05 AM *


aps Jan 27, 2011 04:25 PM

You are doing nothing wrong, but the logger expects to see the echo of an A as the original Hayes modem required and that is not changeable. If it does not get an A it sits in a loop trying and then hanging up the modem until it does get a response.

However, if the Telit modem is running firmware that is similar to the Siemens modems all may not be lost. The requirement for the AT to be sent in those modems is because the modem uses the two characters for autobaud rate detection. If you can turn this off (sometimes simply by fixing the baud rate with AT+IPR) then the Siemens modems at least will echo the A and work with our loggers.


macarli Jan 29, 2011 01:47 PM

Dear Sam and Andrew,

The echo problem is solved by the method as Andrew told. I sent "AT+IPR=9600" to the modem and now CR1000 and my modem can communicate.

However i cant make the IPport connection :(
I made the server-side configuration as Sam mentioned and as in "cs_gprs" manual. Moreover i made the Modem configuration by sending;
AT+IPR=9600
AT+CGDCONT=1,"IP","internet"

And the CR1000 configuration is like;

Setting Name Setting Value
OS Version CR1000.Std.21
Serial Number 16,754
Station Name 16754
PakBus Address 1
Security Level 1 0
Security Level 2 0
Security Level 3 0
UTC Offset -1
Is Router 0
PakBus Nodes Allocation 50
Route Filters Route Filters
Route Filters - End Source
Route Filters - Begin Dest
Route Filters - End Dest
Baud Rate RS232 9600 Fixed
Baud Rate ME 9600 Fixed
Baud Rate COMSDC 9600 Fixed
Baud Rate COM1 9600 Fixed
Baud Rate COM2 0 (Not used for PakBus)
Baud Rate COM3 0 (Not used for PakBus)
Baud Rate COM4 0 (Not used for PakBus)
Beacon Interval RS232 0
Beacon Interval ME 0
Beacon Interval SDC7 0
Beacon Interval SDC8 0
Beacon Interval SDC10 0
Beacon Interval SDC11 0
Beacon Interval COM1 0
Beacon Interval COM2 0
Beacon Interval COM3 0
Beacon Interval COM4 0
Verify Interval RS232 0
Verify Interval ME 0
Verify Interval SDC7 0
Verify Interval SDC8 0
Verify Interval SDC10 0
Verify Interval SDC11 0
Verify Interval COM1 0
Verify Interval COM2 0
Verify Interval COM3 0
Verify Interval COM4 0
Neighbors Allowed RS232 Begin Range End Range
Neighbors Allowed ME Begin Range End Range
Neighbors Allowed SDC7 Begin Range End Range
Neighbors Allowed SDC8 Begin Range End Range
Neighbors Allowed SDC10 Begin Range End Range
Neighbors Allowed SDC11 Begin Range End Range
Neighbors Allowed COM1 Begin Range End Range
Neighbors Allowed COM2 Begin Range End Range
Neighbors Allowed COM3 Begin Range End Range
Neighbors Allowed COM4 Begin Range End Range
Central Routers Central Router Routes
Port Number Via Neighbor Address PakBus Address Response Time
1 4,089 4,089 5,000
USR: Drive Size 0
Files Manager Source Address File Name Number of Files
Include File Name
Max Packet Size 1,000
RS232 Always On Yes
RS232 Hardware Handshaking
Buffer Size 0
RS232 Hardware Handshaking
Timeout 0
Default Gateway 0.0.0.0
Name Servers
Domain Name Servers
0.0.0.0
0.0.0.0
PPP Interface RS232
PPP IP Address 0.0.0.0
Reserved 255.255.255.255
PPP User Name
PPP Password
PPP Dial ATD*99***1#
PPP Dial Response CONNECT
PakBus/TCP Service Port 6,785
PakBus/TCP Client Connections
PakBus/TCP Client Connections Port Number
212.174.166.156 6,785
PakBus/TCP Password
HTTP Service Port 80
FTP Service Port 21
FTP User Name
FTP Password
Ping Enabled 1
FTP Enabled 1
Telnet Enabled 1
HTTP Enabled 1
Transport Layer Security (TLS)
Enabled 0
Reserved 0
TLS Certificate File Name
TLS Private Key File Name
TLS Private Key Password
IP Trace COM Port Inactive
IP Trace Code 0
TCP/IP Info ppp ip: 0.0.0.0 ppp mask: 255.0.0.0 ppp gw: 0.0.0.0

With this settings, I can made GPRS connection by using Hyperterminal. Moreover, after connecting modem with CR1000, i can see that CR1000 take the CONNECT message from the modem. Also after connect, i can see that both modem and CR1000 send something like "~ }#À!}!}(} }4}!}$}%Ü}"}&} } } } }%}&}(}'}&Ğ}/~~ }#À!}!})} }4}!}$} %Ü}"}&} } } } }%}&}(}'}&ĞFì~~ }#À!}!}*} }4}!}$}%Ü}"}&} } } }}%}&}(}'}&ĞŒQ~~ }#À !}!}+} }4}!}$}%Ü}"}&} } } } }%}&}(}'}&ĞÅÂ~~ }#À!}!}!} }4}"}&} } } } }#}$À#}%}&`t} } ğ]~~ }".
This is for PPP connection i think. But i cant made the IPport connection with server(or maybe PPP connection with modem). I got lost in this :(
Any idea?
Thanks


aps Jan 30, 2011 11:23 AM

Please send me you email address and I will send info on how to further debug this. My email address is:

andrew dot sandford at campbellsci dot co dot uk


ariffu Sep 14, 2011 12:01 PM

Hi SAM,

Could you sent me the example program for options:

Write data using TableFile instruction, then FTP the file to their server
Tq


Sam Sep 15, 2011 12:19 AM

Here is an example of FTP'ing data baled using TableFile - without retries.

Public PTemp, batt_volt

Public OutStat As Boolean
Public LastFileName As String * 31

Const Host = "your.ftp.server"
Const User = "user"
Const Pass = "pass"
Const RDir = "/your/remote/directory/path"
Public RName As String * 63
Public Success As Boolean

'DATA TABLES
DataTable (Test,1,1000)
DataInterval (0,15,Sec,10)
TableFile ("USR:Test_",8,5,0,60,Sec,OutStat,LastFileName)
Sample (1,batt_volt,FP2)
Sample (1,PTemp,FP2)
EndTable

DataTable(TxLog,1,1000)
Sample (1,Success,Boolean)
Sample (1,LastFileName,String)
Sample (1,RName,String)
EndTable

'MAIN PROGRAM
BeginProg
SetStatus("USRDriveSize",1000000)

Scan (1,Sec,0,0)
PanelTemp (PTemp,250)
Battery (batt_volt)
CallTable Test
If OutStat Then TriggerSequence (1,100)
NextScan

SlowSequence
Do
WaitTriggerSequence
SemaphoreGet (1)
RName = RDir & Replace (LastFileName,"USR:","")
If FileTime(LastFileName) > 0 Then 'if file exists
Success = FALSE
Success = FTPClient (Host,User,Pass,LastFileName,RName,2) 'attempt to ftp
CallTable (TxLog) 'diagnostics table
EndIf
SemaphoreRelease (1)
Loop
EndSequence

EndProg

Log in or register to post/reply in the forum.