rustyg Posted April 14, 2010 Share Posted April 14, 2010 Hello, My technicians asked me to add alarms that poll an IP address down line on our canopy network. So far, I've set up a Canopy device and added an IP address for the particular radio I want to communicate with. If I go to the Comm monitor I am receiving data from the device. My question: What is a simple way to poll the IP address of the radio and send that to a Boolean channel for alarming? I just need a 0 or 1 to tell me whether I can communicate with the radio or not. Thanks, Rusty Goldsmith Link to comment Share on other sites More sharing options...
AzeoTech Posted April 14, 2010 Share Posted April 14, 2010 You can just create a little sequence that does it. First create a channel, say "RadioStatus", device type Test, Digital Out. Then a sequence that looks something like this: while(1) try device.mydevice.write("some out string") device.mydevice.read(1) // read one character to see if it responded RadioStatus = 1 // got this far, must be good! catch() // one of the comm commands timed out, fail! RadioStatus = 0 ? strLastError // you can get rid of this if you want endcatch delay(1) // check once a second endwhile Link to comment Share on other sites More sharing options...
rustyg Posted April 19, 2010 Author Share Posted April 19, 2010 Administrator, Hey, thanks a lot. I think that little sequence is doing the trick. I'm getting 1's back for an active connection so I think it is working well. I'll try some more tests, but I think its looking good. Thanks a lot, Rusty Goldsmith Link to comment Share on other sites More sharing options...
rustyg Posted April 21, 2010 Author Share Posted April 21, 2010 Hey, thanks for replying to my last question. I have another question from creating more of these channels. I have 34 of these canopy radios that I want to monitor, and I'll have over 100 radios once the network is completed. I noticed that as I simply added more of these connections in the "Serial Port/ Ethernet Port" box of the "Ethernet / Serial Device" menu that I began to get an overload of errors, even after only adding 10 of these ports. The error says: 04/21/10 18:06:23:336 Socket error: 10049 I get a new error message just like this about every half second and I assume that its because it can't communicate with the radio at some of these ports I added. I'm not even trying to monitor the port yet and want the sequence to do the polling every 10 minutes instead. I couldn't find anything about an "error 10049" in the manual. What can I do to stop this error? Rusty Goldsmith Link to comment Share on other sites More sharing options...
AzeoTech Posted April 22, 2010 Share Posted April 22, 2010 Socket errors are standard socket errors and you can just search the Internet for their meaning. 10049 means the address is not available, i.e. there is nothing on the other side to connect to. With your polling rate, instead of creating separate devices, I would simply create one device and change the address as you loop through. Its something like: device.mydevice.address = "10.0.0.1" device.mydevice.initcomm() I'd create an array of strings containing all the addresses and a simple loop to loop through them. Make sure and put the comms inside a try/catch block so you catch any connection errors. Something like: private string addresses = {"10.0.0.1","10.0.0.2","10.0.0.3"} private nexttime = systime() while (1) for (private i = 0, i < numrows(addresses), i++) try device.mydevice.address = addresses[i] device.mydevice.initcomm() // ... do comms on the device catch() ? strLastError // display error in command alert for debugging endcatch endfor nexttime += 600 // wait 10 minutes total loop time waituntil(nexttime) endwhile I'm doing this off the cuff, so there might be some typos, but that's the general gist. Link to comment Share on other sites More sharing options...
rustyg Posted May 11, 2010 Author Share Posted May 11, 2010 Administrator, I was out for a couple weeks so it took me a while to get back to this code. I tried implementing the code you sent me but I think there might be a problem with line 6: device.mydevice.address = addresses I'm not sure if I implemented the address looping correctly. My code is cycling through 7 loops and returning a 1 for each address; however, I shouldn't get all 1s because I threw in some bad IPs. Here what I made from your example code: private string addresses = {"172.16.157.122","172.16.157.125","172.16.157.170", "172.16.157.173","172.16.157.162","172.16.157.165", "172.16.157.123"} private nexttime = systime() while (1) for (private i = 0, i < numrows(addresses), i++) try device.CanopyLinks.address = addresses[i] device.CanopyLinks.initcomm() // ... do comms on the device device.CanopyLinks.write("hello") device.CanopyLinks.read(1) // read one character to see if it responded Link[i] = 1 catch() ? strLastError // display error in command alert for debugging Link[i] = 0 endcatch endfor nexttime += 600 // wait 10 minutes total loop time waituntil(nexttime) endwhile Link to comment Share on other sites More sharing options...
AzeoTech Posted May 11, 2010 Share Posted May 11, 2010 Hmm, worked perfectly for me. I got 6 Timeout errors displayed in the command/alert, one each second (one second timeout on CanopyLinks). Then when it stopped, link was equal to {0, 0, 0, 0, 0, 0} Did you get any messages in command/alert? Try adding: ? device.canopylinks.address after you do the assignment. Link to comment Share on other sites More sharing options...
rustyg Posted May 11, 2010 Author Share Posted May 11, 2010 Administrator, I did try the line you gave me, but it didn't seem to change the results. I got link = {1,1,1,1,1,1}. I did not get any links in the error box; I think its trying to read the same address every time (172.16.157.122 which I assigned to the device). It should not be able to read the last couple of links. I expect to get link = {1,1,1,1,0,0} because I put bad IPs in there for the test. Maybe it is the way I set up the device, CanopyLinks. I set CanopyLinks to IP address 172.16.157.122 which should be a good link. Should I set up the device differently? Device Name: Canopy Links Port/Connection Name: Radio IP address: 172.16.157.122 Port: 23 Timeout: 3000 ms Link to comment Share on other sites More sharing options...
AzeoTech Posted May 11, 2010 Share Posted May 11, 2010 Did you add this line: ? device.canopylinks.address You should see each of the IP's in the command / alert Link to comment Share on other sites More sharing options...
rustyg Posted May 11, 2010 Author Share Posted May 11, 2010 Administrator, No it did not display the IPs in the command/alert box when i added that line, but it is still giving me back 1s. Link to comment Share on other sites More sharing options...
rustyg Posted May 14, 2010 Author Share Posted May 14, 2010 Administrator, It took me some time, but I figured out that I did indeed set up the device incorrectly. Page 329 on the manual says I have to leave the IP Address of the device blank for a placeholder. I had set up the device with the first IP Address in the program which caused it to work incorrectly. Between all the information you've given me and what I've read in the manual I can now get this working the way I need it. I think I've got it from here. Thanks again, Rusty Goldsmith Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.