Help open file!
Leha
Posts: 37
Where here error?
PROGRAM_NAME='Weather'
DEFINE_DEVICE
MODERO8400 = 10001:1:0
dvInternet = 0:3:0
DEFINE_CONSTANT
char SiteIP[16] = '93.81.239.44';
integer IntSitePort = 80;
integer InternetWait = 30;
DEFINE_TYPE
DEFINE_VARIABLE
INTEGER InternetOnline;
char tmpRecieve[2048];
DEFINE_LATCHING
DEFINE_MUTUALLY_EXCLUSIVE
DEFINE_START
WAIT 30 { IP_CLIENT_OPEN(dvInternet.port,SiteIP, IntSitePort, IP_TCP) }
DEFINE_EVENT
DATA_EVENT[dvInternet]
{
ONLINE :
{
InternetOnline = TRUE;
}
OFFLINE :
{
InternetOnline = FALSE;
WAIT InternetWait IP_CLIENT_OPEN(dvInternet.Port, SiteIP, IntSitePort, IP_TCP);
}
ONERROR :
{
SWITCH (DATA.NUMBER)
{
CASE 9: {BREAK}
CASE 17: {BREAK}
DEFAULT:
{
IP_CLIENT_CLOSE(dvInternet.Port);
InternetOnline = FALSE;
WAIT InternetWait IP_CLIENT_OPEN(dvInternet.Port, SiteIP, IntSitePort, IP_TCP);
}
}
}
STRING :
{
tmpRecieve = data.text;
SEND_STRING 0:1:0,"'File',itoa(tmpRecieve)"
}
}
DEFINE_PROGRAM
//WAIT 200
// {
// send_string dvInternet,'http://zinna.ru/pogoda/yahooWeather.php';
// }
WAIT 200
{
SEND_STRING dvInternet, "'GET /pagoda/yahooWeather.php HTTP/1.1',$0D,$0A,
'HOST: zinna.ru',$0D,$0A,
'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.5',$0D,$0A,
'Accept: */*',$0D,$0A,
'Accept-Language: en-us',$0D,$0A,
$0D,$0A";
}
PROGRAM_NAME='Weather'
DEFINE_DEVICE
MODERO8400 = 10001:1:0
dvInternet = 0:3:0
DEFINE_CONSTANT
char SiteIP[16] = '93.81.239.44';
integer IntSitePort = 80;
integer InternetWait = 30;
DEFINE_TYPE
DEFINE_VARIABLE
INTEGER InternetOnline;
char tmpRecieve[2048];
DEFINE_LATCHING
DEFINE_MUTUALLY_EXCLUSIVE
DEFINE_START
WAIT 30 { IP_CLIENT_OPEN(dvInternet.port,SiteIP, IntSitePort, IP_TCP) }
DEFINE_EVENT
DATA_EVENT[dvInternet]
{
ONLINE :
{
InternetOnline = TRUE;
}
OFFLINE :
{
InternetOnline = FALSE;
WAIT InternetWait IP_CLIENT_OPEN(dvInternet.Port, SiteIP, IntSitePort, IP_TCP);
}
ONERROR :
{
SWITCH (DATA.NUMBER)
{
CASE 9: {BREAK}
CASE 17: {BREAK}
DEFAULT:
{
IP_CLIENT_CLOSE(dvInternet.Port);
InternetOnline = FALSE;
WAIT InternetWait IP_CLIENT_OPEN(dvInternet.Port, SiteIP, IntSitePort, IP_TCP);
}
}
}
STRING :
{
tmpRecieve = data.text;
SEND_STRING 0:1:0,"'File',itoa(tmpRecieve)"
}
}
DEFINE_PROGRAM
//WAIT 200
// {
// send_string dvInternet,'http://zinna.ru/pogoda/yahooWeather.php';
// }
WAIT 200
{
SEND_STRING dvInternet, "'GET /pagoda/yahooWeather.php HTTP/1.1',$0D,$0A,
'HOST: zinna.ru',$0D,$0A,
'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.5',$0D,$0A,
'Accept: */*',$0D,$0A,
'Accept-Language: en-us',$0D,$0A,
$0D,$0A";
}
0
Comments
1) The SEND_STRING under DEFINE_PROGRAM is sending the string every 20 seconds without checking the state of InternetOnline first to see if the port is open. You also probably don’t want to be retrieving the weather every 20 seconds.
2) The SEND_STRING 0 inside the STRING: handler does not need an ITOA() conversion since tmpRecieve is a character array.
The program doesn't address on server, variable tmpRecieve the empty. Why it doesn't work?
Try changing
to
I would also leave out the stuff after the "Host:" line.
Are you sure that IP is a valid weather address? I'm getting an access forbidden error when I navigate to it.
Also, this is probably stating the obvious but you need to make sure the Netlinx master is configured correctly for Internet access.
That's true for Axcess only. Netlinx doesn't have that limitation.
Line 1 :: IPSocketManConnectTask - errno = 65 (errno = 0x41) addr:93.81.239.44:80 - 22:43:13
Line 2 :: Memory Available = 36333360 <16112> - 22:43:13
Line 3 :: CIpEvent::OnError 0:3:1 - 22:43:13
Line 4 :: CIpSocketMan::ProcessPLPacket - Socket Already Closed - 22:43:13
Line 5 :: CIpEvent::OnError 0:3:1 - 22:43:13
Line 6 :: IPSocketManConnectTask - errno = 65 (errno = 0x41) addr:93.81.239.44:80 - 22:43:16
Line 7 :: CIpEvent::OnError 0:3:1 - 22:43:16
Line 8 :: CIpSocketMan::ProcessPLPacket - Socket Already Closed - 22:43:16
Line 9 :: CIpEvent::OnError 0:3:1 - 22:43:16
Line 10 :: IPSocketManConnectTask - errno = 65 (errno = 0x41) addr:93.81.239.44:80 - 22:43:19
Line 11 :: CIpEvent::OnError 0:3:1 - 22:43:19
Line 12 :: CIpSocketMan::ProcessPLPacket - Socket Already Closed - 22:43:19
Line 13 :: CIpEvent::OnError 0:3:1 - 22:43:19
Line 14 :: SendString to socket-local port (3) invalid - 22:43:20
Line 15 :: SendString to socket-local port (3) invalid - 22:43:20
Line 16 :: CIpEvent::OnError 0:3:1 - 22:43:20
Line 17 :: CIpEvent::OnError 0:3:1 - 22:43:20
Line 18 :: IPSocketManConnectTask - errno = 65 (errno = 0x41) addr:93.81.239.44:80 - 22:43:22
Line 19 :: CIpEvent::OnError 0:3:1 - 22:43:22
Line 20 :: CIpSocketMan::ProcessPLPacket - Socket Already Closed - 22:43:22
Line 21 :: CIpEvent::OnError 0:3:1 - 22:43:22
Line 22 :: IPSocketManConnectTask - errno = 65 (errno = 0x41) addr:93.81.239.44:80 - 22:43:25
Line 23 :: CIpEvent::OnError 0:3:1 - 22:43:25
Line 24 :: CIpSocketMan::ProcessPLPacket - Socket Already Closed - 22:43:25
Line 25 :: CIpEvent::OnError 0:3:1 - 22:43:25
PROGRAM_NAME='Weather'
DEFINE_DEVICE
MODERO8400 = 10001:1:0
dvInternet = 0:3:0
DEFINE_CONSTANT
char SiteIP[16] = '93.81.239.44';
integer IntSitePort = 80;
integer InternetWait = 30;
DEFINE_TYPE
DEFINE_VARIABLE
INTEGER InternetOnline;
char tmpRecieve[255];
DEFINE_START
WAIT 30 { IP_CLIENT_OPEN(dvInternet.port,SiteIP, IntSitePort, IP_TCP) }
DEFINE_EVENT
DATA_EVENT[dvInternet]
{
ONLINE :
{
InternetOnline = TRUE;
}
OFFLINE :
{
InternetOnline = FALSE;
WAIT InternetWait IP_CLIENT_OPEN(dvInternet.Port, SiteIP, IntSitePort, IP_TCP);
}
ONERROR :
{
SWITCH (DATA.NUMBER)
{
CASE 9: {BREAK}
CASE 17: {BREAK}
DEFAULT:
{
IP_CLIENT_CLOSE(dvInternet.Port);
InternetOnline = FALSE;
WAIT InternetWait IP_CLIENT_OPEN(dvInternet.Port, SiteIP, IntSitePort, IP_TCP);
}
}
}
STRING :
{
tmpRecieve = data.text;
SEND_STRING 0:1:0,"'File',itoa(tmpRecieve)"
}
}
DEFINE_PROGRAM
//WAIT 200 (*..*)
// {
// send_string dvInternet,'http://zinna.ru/pogoda/yahooWeather.php';
// }
WAIT 200 (*Обновление данных каждую минуту*)
{
SEND_STRING dvInternet, "'GET /pagoda/yahooWeather.php HTTP/1.1',$0D,$0A"
SEND_STRING dvInternet, "'HOST: zinna.ru',$0D,$0A"
}
http://zinna.ru/pogoda/yahooWeather.php
this file...
Plus your ITOA on the data.text isn't necessarily the right approach either. From what I can tell I think you're only going to get the number "4" in your diagnostics printout if you leave that in there and manage to get a connection.
Line 14 :: SendString to socket-local port (3) invalid - 22:43:20
Line 15 :: SendString to socket-local port (3) invalid - 22:43:20