Menu

libnodave - CPU 314 - CP 343-1 in TCP

Help
2008-07-30
2013-05-09
  • francesco Iannone

    Hi

    I'd like to ask you a little bit help

    I'm using libnodave librery on Linux with gcc. It sounds fine , but whe I try to read 1 byte in DB2 on CPU the program return NULL value in data , instead the value on CPU is not NULL.

    This is my output

    ./testISO_TCP -d 192.107.90.237
    openSocket: enter OpenSocketopenSocket: OpenSocket: socket is 3
    openSocket: Connected to host: 192.107.90.237
    openSocket: setsockopt Success 0
    send packet: :
    0:0x03,0x00,0x00,0x16,0x11,0xE0,0x00,0x00,0x00,0x01,0x00,0xC1,0x02,0x01,0x00,0xC2,
    10:0x02,0x01,0x02,0xC0,0x01,0x09,
    readISOpacket: 22 bytes read, 22 needed
    readISOpacket: packet:
    0:0x03,0x00,0x00,0x16,0x11,0xD0,0x00,0x01,0x44,0x31,0x00,0xC0,0x01,0x09,0xC1,0x02,
    10:0x01,0x00,0xC2,0x02,0x01,0x02,
    IF1 daveConnectPLC() step 1. got packet: :
    0:0x03,0x00,0x00,0x16,0x11,0xD0,0x00,0x01,0x44,0x31,0x00,0xC0,0x01,0x09,0xC1,0x02,
    10:0x01,0x00,0xC2,0x02,0x01,0x02,
    PDU header:
    0:0x32,0x01,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,
    plen: 8 dlen: 0
    Parameter:
    0:0xF0,0x00,0x00,0x01,0x00,0x01,0x03,0xC0,
    _daveExchange PDU number: 65535
    IF1 enter _daveExchangeTCP
    send packet: :
    0:0x03,0x00,0x00,0x19,0x02,0xF0,0x80,0x32,0x01,0x00,0x00,0xFF,0xFF,0x00,0x08,0x00,
    10:0x00,0xF0,0x00,0x00,0x01,0x00,0x01,0x03,0xC0,
    readISOpacket: 27 bytes read, 27 needed
    readISOpacket: packet:
    0:0x03,0x00,0x00,0x1B,0x02,0xF0,0x80,0x32,0x03,0x00,0x00,0xFF,0xFF,0x00,0x08,0x00,
    10:0x00,0x00,0x00,0xF0,0x00,0x00,0x01,0x00,0x01,0x00,0xF0,
    IF1 _daveExchangeTCP res from read 27
    result of exchange: 0
    PDU header:
    0:0x32,0x03,0x00,0x00,0xFF,0xFF,0x00,0x08,0x00,0x00,0x00,0x00,
    plen: 8 dlen: 0
    Parameter:
    0:0xF0,0x00,0x00,0x01,0x00,0x01,0x00,0xF0,
    error: ok

    *** Partner offered PDU length: 240 used limit 240

    Connected.
    Trying to read 1 byte from data block 2.
    I'm using --res=daveReadBytes(dc,daveDB,2,0,1,NULL)--
    Press return to continue.

    PDU header:
    0:0x32,0x01,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,
    plen: 14 dlen: 0
    Parameter:
    0:0x04,0x01,0x12,0x0A,0x10,0x02,0x00,0x01,0x00,0x02,0x84,0x00,0x00,0x00,
    _daveExchange PDU number: 65536
    IF1 enter _daveExchangeTCP
    send packet: :
    0:0x03,0x00,0x00,0x1F,0x02,0xF0,0x80,0x32,0x01,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,
    10:0x00,0x04,0x01,0x12,0x0A,0x10,0x02,0x00,0x01,0x00,0x02,0x84,0x00,0x00,0x00,
    readISOpacket: 26 bytes read, 26 needed
    readISOpacket: packet:
    0:0x03,0x00,0x00,0x1A,0x02,0xF0,0x80,0x32,0x03,0x00,0x00,0x00,0x00,0x00,0x02,0x00,
    10:0x05,0x00,0x00,0x04,0x01,0xFF,0x04,0x00,0x08,0x00,
    IF1 _daveExchangeTCP res from read 26
    result of exchange: 0
    PDU header:
    0:0x32,0x03,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x05,0x00,0x00,
    plen: 2 dlen: 5
    Parameter:
    0:0x04,0x01,
    Data     :
    0:0xFF,0x04,0x00,0x08,0x00,
    Data hdr :
    0:0xFF,0x04,0x00,0x08,
    Data     :
    0:0x00,
    error: ok
    _daveSetupReceivedPDU() returned: 0=ok
    _daveTestReadResult() returned: 0=ok
    DB2:DB0: 0

    greetings

     
    • Nobody/Anonymous

      I do not quite understand what the problem is you describe by:
      "I'm using libnodave librery on Linux with gcc. It sounds fine , but whe I try to read 1 byte in DB2 on CPU the program return NULL value in data , instead the value on CPU is not NULL."
      The debug output looks good.
      The result is that you are reading DBB0 from DB2.
      This byte is 0.
      I do not know what you mean by "NULL".
      If you think the value of DB2.DBB0 is not 0 in your CPU, I can immagine 2 possible reasons for confusion:
      1. You read DB2.DBW0 or DB2.DBD0 with another toll, e.g. Step7 and the value is not 0 but below 256 in case of DBW0. Then please be aware that S7 uses big endian, so the high byte of DBW0 is in DBB0 and the low byte in DBB1. Please verify reading more bytes.
      2. Libnodave reads in any moment probably not synchronized with PLC program execution cycle. So if you have a program like:
      L 22
      T DB2.DBB0
      L 0
      T DB2.DBB0
      you may read 22 or 0 depending on when the read occurs.

      Thomas

       
    • francesco Iannone

      Thanks a lot Thomas

      However , as you said , I' m reading DBB0 from DB2 (the first byte of data block 2).
      This block on my CPU is not 0 (NULL means 0 for me). I'm reading DB2 with STEP 7 and I read it on CPU "on line".
      I'm seeing:
      Blocks: OB1, DB1, DB2
      and in DB2
      "start struct"
      name_var  -----   INT (type) ------ 10 (value)------ (comment)
      "end struct"

        I'm using "testISOTCP" program, modified to rad DB2.DBB0 with
      res=daveReadBytes(dc,daveDB,2,0,1,NULL)

      but it reads 0

      thanks once again

      greetings 

       
      • Nobody/Anonymous

        You said:
        "I'm using "testISOTCP" program, modified to rad DB2.DBB0 with
        res=daveReadBytes(dc,daveDB,2,0,1,NULL) "
        I am well aware of that.
        What I did not know from your former post was that you have a struct in your DB1!
        I am very shure that the problem is with the memory layout of that struct!

        Pleaes increase the number of bytes, e.g.:
        res=daveReadBytes(dc,daveDB,2,0,10,NULL) "
        Then let your program show every single of these bytes.
        Or see the debug output: you now have a line like:
        0xff 0x04 0x00 0x08 0x00, the last byte being the data.
        With ten bytes it should look like:
        0xff 0x04 0x00 0x50 0x00, byte1, byte2,..,byte9

        Thomas

         
    • francesco Iannone

      Thanks to be so patient with me (considering we are under summer holidays)
      I tried to read the first 10 bytes and obviusly the function "davereadbytes" rutrn error 5 because I have just only one INT in DB2.
      The output first is belowe. Then I tried to read 2 bytes and the section data of PDU has two bytes 0 (as you can see with output 2nd.

      greetings and thanks once again

      output first:
      ............
      Connected.
      Trying to read 10 byte from data block 2.
      I'm using --res=daveReadBytes(dc,daveDB,2,0,10,NULL)--
      Press return to continue.

      PDU header:
      0:0x32,0x01,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,
      plen: 14 dlen: 0
      Parameter:
      0:0x04,0x01,0x12,0x0A,0x10,0x02,0x00,0x0A,0x00,0x02,0x84,0x00,0x00,0x00,
      _daveExchange PDU number: 65536
      IF1 enter _daveExchangeTCP
      send packet: :
      0:0x03,0x00,0x00,0x1F,0x02,0xF0,0x80,0x32,0x01,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,
      10:0x00,0x04,0x01,0x12,0x0A,0x10,0x02,0x00,0x0A,0x00,0x02,0x84,0x00,0x00,0x00,
      readISOpacket: 25 bytes read, 25 needed
      readISOpacket: packet:
      0:0x03,0x00,0x00,0x19,0x02,0xF0,0x80,0x32,0x03,0x00,0x00,0x00,0x00,0x00,0x02,0x00,
      10:0x04,0x00,0x00,0x04,0x01,0x05,0x00,0x00,0x00,
      IF1 _daveExchangeTCP res from read 25
      result of exchange: 0
      PDU header:
      0:0x32,0x03,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x04,0x00,0x00,
      plen: 2 dlen: 4
      Parameter:
      0:0x04,0x01,
      Data     :
      0:0x05,0x00,0x00,0x00,
      Data hdr :
      0:0x05,0x00,0x00,0x00,
      Data     :
      error: ok
      _daveSetupReceivedPDU() returned: 0=ok
      _daveTestReadResult() returned: 5=the desired address is beyond limit for this PLC
      failed! (5)
      Trying to read 16 bytes from FW0.

      output 2nd
      .............
      onnected.
      Trying to read 2 byte from data block 2.
      I'm using --res=daveReadBytes(dc,daveDB,2,0,2,NULL)--
      Press return to continue.

      PDU header:
      0:0x32,0x01,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,
      plen: 14 dlen: 0
      Parameter:
      0:0x04,0x01,0x12,0x0A,0x10,0x02,0x00,0x02,0x00,0x02,0x84,0x00,0x00,0x00,
      _daveExchange PDU number: 65536
      IF1 enter _daveExchangeTCP
      send packet: :
      0:0x03,0x00,0x00,0x1F,0x02,0xF0,0x80,0x32,0x01,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,
      10:0x00,0x04,0x01,0x12,0x0A,0x10,0x02,0x00,0x02,0x00,0x02,0x84,0x00,0x00,0x00,
      readISOpacket: 27 bytes read, 27 needed
      readISOpacket: packet:
      0:0x03,0x00,0x00,0x1B,0x02,0xF0,0x80,0x32,0x03,0x00,0x00,0x00,0x00,0x00,0x02,0x00,
      10:0x06,0x00,0x00,0x04,0x01,0xFF,0x04,0x00,0x10,0x00,0x00,
      IF1 _daveExchangeTCP res from read 27
      result of exchange: 0
      PDU header:
      0:0x32,0x03,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x06,0x00,0x00,
      plen: 2 dlen: 6
      Parameter:
      0:0x04,0x01,
      Data     :
      0:0xFF,0x04,0x00,0x10,0x00,0x00,
      Data hdr :
      0:0xFF,0x04,0x00,0x10,
      Data     :
      0:0x00,0x00,
      error: ok
      _daveSetupReceivedPDU() returned: 0=ok
      _daveTestReadResult() returned: 0=ok
      DB2:DB0: 0
      Trying to read 16 bytes from FW0.

      greetings

       
    • Nobody/Anonymous

      You wrote:
      "I tried to read the first 10 bytes and obviusly the function "davereadbytes" rutrn error 5 because I have just only one INT in DB2.
      The output first is belowe. Then I tried to read 2 bytes and the section data of PDU has two bytes 0 (as you can see with output 2nd. "
      What I CANNOT see from it is whether you now are satisfied with it!
      I had another look at your struct:
      "start struct"
      name_var ----- INT (type) ------ 10 (value)------ (comment)
      "end struct"
      You seem to set it to 10 somehow. If this is an INITIAL value, the value may later be overwritten. I do not know when and under which conditions an initial value is copied to the working memory.
      Please look at your DB2 in Step7 just if it were an arry of bytes:
      Try to see variables DB2.DBB0 and DB2.DBB1
      They should be 0 also.
      Next you might try to set values from step7 writing to DB2.DBB0 and DB2.DBB1 and if you see the values there, I am sure you will also see them in Libnodave!

       
    • francesco Iannone

      You wrote:

      "You seem to set it to 10 somehow. If this is an INITIAL value, the value may later be overwritten. I do not know when and under which conditions an initial value is copied to the working memory"

      You are rigth, I solved my problem and "daveReadBytes" works fine.

      I wronged because I didn't know that the "initial value" of STEP 7 isn't the "actual value" (or so called working memory).

      Thanks a lot for your patient.

      greetings

       

Anonymous
Anonymous

Add attachments
Cancel