Newbie Question
kevsach
Junior Member
Hi,
I'm working at a university that uses AMX across the campus in our lecture rooms. We want to connect an occupancy sensor to the IO ports on the controller, and have the controller do a HTTP Post request to the server when occupancy is detected. I have written the following by looking through some of our other programs written by integrators and some help file trawling! however it fails to compile saying the Channel_Event line is invalid syntax.... any help greatly appreciated!
PROGRAM_NAME='OCCUPANCY'
define_device
dvIO = 5001:17:0
dvServer = 0:5:0
CHANNEL_EVENT [dvIO,2]
{
OFF: {
IP_Client_open(dvServer.PORT,'ip of server',80,IP_TCP)
SEND_STRING dvServer,"'POST /pcav/senddata.php HTTP/1.0',13,10"
SEND_STRING dvServer,"'From: bob@thebuilder.com',13,10"
SEND_STRING dvServer,"'User-Agent: HTTPTool/1.0',13,10"
SEND_STRING dvServer,"'Content-Type: application/x-www-form-urlencoded',13,10"
SEND_STRING dvServer,"'Content-Length: 32',13,10"
SEND_STRING dvServer,"13,10"
SEND_STRING dvServer,"'Someones Here!!!!!'"
}
}
I'm working at a university that uses AMX across the campus in our lecture rooms. We want to connect an occupancy sensor to the IO ports on the controller, and have the controller do a HTTP Post request to the server when occupancy is detected. I have written the following by looking through some of our other programs written by integrators and some help file trawling! however it fails to compile saying the Channel_Event line is invalid syntax.... any help greatly appreciated!
PROGRAM_NAME='OCCUPANCY'
define_device
dvIO = 5001:17:0
dvServer = 0:5:0
CHANNEL_EVENT [dvIO,2]
{
OFF: {
IP_Client_open(dvServer.PORT,'ip of server',80,IP_TCP)
SEND_STRING dvServer,"'POST /pcav/senddata.php HTTP/1.0',13,10"
SEND_STRING dvServer,"'From: bob@thebuilder.com',13,10"
SEND_STRING dvServer,"'User-Agent: HTTPTool/1.0',13,10"
SEND_STRING dvServer,"'Content-Type: application/x-www-form-urlencoded',13,10"
SEND_STRING dvServer,"'Content-Length: 32',13,10"
SEND_STRING dvServer,"13,10"
SEND_STRING dvServer,"'Someones Here!!!!!'"
}
}
Comments
-
You need a DEFINE_EVENT line before your channel event. Something needs to tell the compiler you are switching sections.
-
Hi,
I'm working at a university that uses AMX across the campus in our lecture rooms. We want to connect an occupancy sensor to the IO ports on the controller, and have the controller do a HTTP Post request to the server when occupancy is detected. I have written the following by looking through some of our other programs written by integrators and some help file trawling! however it fails to compile saying the Channel_Event line is invalid syntax.... any help greatly appreciated!
PROGRAM_NAME='OCCUPANCY'
define_device
dvIO = 5001:17:0
dvServer = 0:5:0
CHANNEL_EVENT [dvIO,2]
{
OFF: {
IP_Client_open(dvServer.PORT,'ip of server',80,IP_TCP)
SEND_STRING dvServer,"'POST /pcav/senddata.php HTTP/1.0',13,10"
SEND_STRING dvServer,"'From: bob@thebuilder.com',13,10"
SEND_STRING dvServer,"'User-Agent: HTTPTool/1.0',13,10"
SEND_STRING dvServer,"'Content-Type: application/x-www-form-urlencoded',13,10"
SEND_STRING dvServer,"'Content-Length: 32',13,10"
SEND_STRING dvServer,"13,10"
SEND_STRING dvServer,"'Someones Here!!!!!'"
}
}
not having the rig right in front of me to test.... I'd suggest trying to combine the whole set of strings into one string.
something like:OFF: { stack_var message[300] IP_Client_open(dvServer.PORT,'ip of server',80,IP_TCP) message=" 'POST /pcav/senddata.php HTTP/1.0',13,10, 'From: [email]bob@thebuilder.com[/email]',13,10, 'User-Agent: HTTPTool/1.0',13,10, 'Content-Type: application/x-www-form-urlencoded',13,10, 'Content-Length: 32',13,10, "13,10, 'Someones Here!!!!!' " send_string dvServer , message } -
Not sure about the compiler problem but you shouldn't have the send strings in the channel event since you risk sending to an IP socket that hasn't yet opened. Even though you do first call the port to open it's not an immediate connection. Put the send strings in the online event handler so that when the socket is actually made (online) you then send your strings.
-
Not sure about the compiler problem but you shouldn't have the send strings in the channel event since you risk sending to an IP socket that hasn't yet opened. Even though you do first call the port to open it's not an immediate connection. Put the send strings in the online event handler so that when the socket is actually made (online) you then send your strings.
This is very true Vinning. To be honest, I never try to go down the road on these posts because I just don't know the whole back story. But the OP should note Vinning on this. What I'd really do is create a separate routine for handling commands that will put IP comms into a queue and then let the routine handle when to send a message.
I think this is just good practice any time you have to leave the box for any type of input or output. I've found there's just a strange assumption that the timing of events is cut-and-dried and doesn't need to be handled. Sure, it can be a pain, but so is sussing out quirky problems with strings. It's worse when burning in systems that do IP communication. In burn-in you have a much tighter network under controlled conditions. I've always found IP networks slow down when in the actual installation. So, if I'm relying on the processor to be slow enough, I always get burned at install.
Consequently, I just queue everything. Once you get in the habit of doing it, it come naturally and quickly.
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums
