Home AMX User Forum NetLinx Studio

Help open file!

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";
}

Comments

  • PhreaKPhreaK Posts: 966
    You may want to supply some more info, such as what you are trying to acheive...
  • Joe HebertJoe Hebert Posts: 2,159
    You didn't give us much to go on so I can only offer the following:

    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.
  • LehaLeha Posts: 37
    error

    The program doesn't address on server, variable tmpRecieve the empty. Why it doesn't work?
  • BigsquatchBigsquatch Posts: 216
    From Netlinx keywords help:
    Character Arrays are single element arrays, in which each element has a value from 0 to 255 with a maximum of 255 elements

    Try changing
    char tmpRecieve[2048];
    

    to
    char tmpRecieve[255];
    
  • If you're receiving any error messages, please post them.
    I would also leave out the stuff after the "Host:" line.
    WAIT 200
    {
    SEND_STRING dvInternet, "'GET /pagoda/yahooWeather.php HTTP/1.1',$0D,$0A,
    SEND_STRING dvInternet, "'HOST:zinna.ru',$0D,$0A,$0D,$0A"
    
  • Joe HebertJoe Hebert Posts: 2,159
    Leha wrote: »
    char SiteIP[16] = '93.81.239.44';

    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.
    Bigsquatch wrote: »
    Character Arrays are single element arrays, in which each element has a value from 0 to 255 with a maximum of 255 elements
    That's true for Axcess only. Netlinx doesn't have that limitation.
  • LehaLeha Posts: 37
    Diagnostics...

    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
  • LehaLeha Posts: 37
    Last program

    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"
    }
  • LehaLeha Posts: 37
    Now I try to understand why doesn't work, there are ideas?

    http://zinna.ru/pogoda/yahooWeather.php
    this file...
  • Leha wrote: »
    PROGRAM_NAME='Weather'
    WAIT 200 (*Обновление данных каждую минуту*)
    {
    SEND_STRING dvInternet, "'GET /pagoda/yahooWeather.php HTTP/1.1',$0D,$0A"
    SEND_STRING dvInternet, "'HOST: zinna.ru',$0D,$0A"
    }
    In the code you posted, "pagoda" should be pogoda, and there should be 2 CR,LF ($0D,$0A) after the "HOST:". Also, like Joe, I'm getting a 403 Access Forbidden error when I try to go to the site using either the numeric IP address or the zinna.ru address. I may be mistaken, but if you can't get a connection I don't think it's going to transmit the "GET" command to pull data. You can try it with the corrected string and see if that helps though.

    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.
  • Joe HebertJoe Hebert Posts: 2,159
    I may be mistaken, but if you can't get a connection I don't think it's going to transmit the "GET" command to pull data
    Nope, no mistake. It’s going to try but since the port is never opened successfully the 2 send_strings will fail to transmit as shown by these 2 log messages:

    Line 14 :: SendString to socket-local port (3) invalid - 22:43:20
    Line 15 :: SendString to socket-local port (3) invalid - 22:43:20
Sign In or Register to comment.