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.

Send an HTML command within RTMC or CRBasic


Ehsan Jul 11, 2011 08:39 PM

How can I send an HTML command if a condition occurs in an IF block?

For example:

If a>5
{
-->http://<servername>/axis-cgi/com/ptz.cgi?pan=10&tilt=50&speed=20
}

Else
{
-->http://<servername>/axis-cgi/com/ptz.cgi?pan=30&tilt=70&speed=20
}


Thanks


Sam Jul 12, 2011 02:49 AM

You might try starting with this. Please let us know of any changes you make.

FYI, keep an eye for upcoming OS releases and the HTTPPut and HTTPGet instructions. HTTPGet will "can" this kind of thing up.


<link>http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html</link>

Public a
Public pan, tilt, speed
Public HTTPGetReq As String * 100
Public HTTPGetResp As String * 100
Public IPSocket

BeginProg
Scan(1,min,0,0)
If a > 5 Then
pan = 10
tilt = 50
speed = 20
Else
pan = 30
tilt = 70
speed = 20
EndIf
IPSocket=TCPOpen("http://servername",80,1024)
If IPSocket<>0 Then
HTTPGetReq = "GET /axis-cgi/com/ptz.cgi?pan=" + pan + "&tilt=" + tilt + "&speed=" + speed + " HTTP/1.1" + CHR(13)+CHR(10)
HTTPGetReq = HTTPGetReq + "Host: http://servername" + CHR(13)+CHR(10)
SerialOut(IPSocket,HTTPGetReq,"",0,0)
SerialIn(HTTPGetResp,IPSocket,500,"",100)
EndIf
NextScan
EndProg

* Last updated by: Sam on 7/12/2011 @ 1:25 PM *


Ehsan Jul 12, 2011 07:07 PM

Thanks for your reply.

I am using Loggernet 4.1.016 and it seems the commands you are using for HTTP and Serial do not exist in this version. I am right?
If so, how can I get these commands to work?

Thanks


Sam Jul 12, 2011 07:37 PM

The above is a CRBasic program that would be deployed on a CR1000 with Ethernet link. You said "Send an HTML command within RTMC or CRBasic". I took the CRBasic route. This has no bearing on the version of LoggerNet you are using. Download the latest OS from our website. The EXE will also update CRBasic Editor help and instruction definitions.


Ehsan Jul 12, 2011 07:52 PM

Thank you. I was mistakenly checking the help for CR5000. I found these in CR1000 CRBasic help.

About your code,

HTTPGetReq = "GET /axis-cgi/com/ptz.cgi?pan=" + pan + "&tilt=" + tilt + "&speed=" + speed + " HTTP/1.1" + CHR(13)+CHR(10)
HTTPGetReq = HTTPGetReq + "Host: http://servername" + CHR(13)+CHR(10)

should the second one be HTTPGetResp? or it is correct?

Thanks again


Sam Jul 27, 2011 01:17 AM

Resolved with customer via phone. CR1000 requires NL120, NL115, or modem supporting PPP (e.g. RavenXT) to access network. Network access is required to issue HTTP requests over IP.

* Last updated by: Sam on 7/26/2011 @ 7:17 PM *


Sam Aug 18, 2011 02:12 AM

Update on issue:

Customer is now controlling the pan, tilt, and servo speed of an Axis IP camera based on the reading from a laser range finder. The issue was two fold - 1) A NL115 or NL120 is required to give the CR1000 an IP connection and 2) I had not provided a complete request string for the HTTPGetReq variable

To work with the camera, the HTTP Get request required
1) URI
2) Host
3) User-Agent
4) Authorization
5) Trailing carriage return and line feed

LINE1- GET /axis-cgi/com/ptz.cgi?pan=10&tilt=10&speed=100 HTTP/1.1[CRLF]
LINE2- Host: http://servername[CRLF]
LINE3- User-Agent: Mozilla/4.0
LINE4- Authorization: Basic base64encode(username:password)[CRLF]
LINE5- [CRLF]


or something like:


Public GO as boolean
Public pan, tilt, speed
Public HTTPGetReq As String * 200
Public HTTPGetResp As String * 100
Public IPSocket

BeginProg
Scan(5,sec,0,0)
If GO then
GO = FALSE
IPSocket=TCPOpen("http://servername",80,1024)
If IPSocket<>0 Then

HTTPGetReq = "GET /axis-cgi/com/ptz.cgi?pan=" + pan + "&tilt=" + tilt + "&speed=" + speed + " HTTP/1.1" + CHR(13)+CHR(10)

HTTPGetReq = HTTPGetReq + "Host: http://servername" + CHR(13)+CHR(10)

HTTPGetReq = HTTPGetReq + "User-Agent: Mozilla/4.0" + CHR(13)+CHR(10)

HTTPGetReq = HTTPGetReq + "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" + CHR(13)+CHR(10)

HTTPGetReq = HTTPGetReq + CHR(13)+CHR(10)

SerialOut(IPSocket,HTTPGetReq,"",0,0)
SerialIn(HTTPGetResp,IPSocket,500,"",100)

EndIf
Endif
NextScan
EndProg

* Last updated by: Sam on 8/17/2011 @ 8:14 PM *

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