2079 Network stack...

Started by zoneblue, January 18, 2016, 10:24:43 PM

Previous topic - Next topic

zoneblue

Ok so something new has occured. 11 days ago i fitted the new MNLP. After 5 days up time newmodbusd starting returning error code 4, which caused a new socket to be requested (and which reconnects for one second then repeats). Its been running in that state for the last 6 days. Code 4 is caused by the C below. This is Ross W's code which i added the error checking to (in order to get to cleanly reconnect after controller reboots).

Ive rebooted it and normal stack behavior resumed. Ill run this as is again until this reoccurs at which point ill remove the MNLP to see if that is the cause.

/**
* MODBUS_READ_REGISTERS
* Reads modbus registers via network socket
* Store in buffer array.
*
* @arg: (int) addr   , starting *register*
* @arg: (int) number , number of 16-bit registers to read
* @arg: (int) offset , where registers to be stored in the buffer
* @return (int) 0 ok, >0 fail
*
*/
int modbus_read_registers(int addr, int number, int offset) {
id[0]=0;               // Transaction ID MSB
id[1]=2;               // Transaction ID LSB
id[2]=0;               // modbus protocol 0 MSB
id[3]=0;               // modbus protocol 0 LSB
id[4]=0;               // bytes following MSB
id[5]=6;               // bytes following LSB
id[6]=255;             // ident
id[7]=3;               // read multiple registers/addresses
id[8]= (addr-1)>>8;    // starting address (MSB)
id[9]= (addr-1)&0xff;  // starting address (LSB)
id[10]=0;              // Addresses to read (MSB)
id[11]=number;         // Addresses to read (LSB)

//open a new network socket to the classic
if (!sock && classic_connect()) return(1);

//socket request
if (write(sock,&id, 12) != 12) return(2);

//read modbus encapsulation
len= read(sock, id, 7);
if (len<0) return(3);

//read response code and bytecount
len= read(sock, id, 2);
if (len<2 || (id[0]) != 3 || (id[1]&0xff) != number<<1) {
return(4); //socket reply error
}

//read response as advised
n= id[1]&0xff;           // number of bytes to read
len= read(sock, buf+(offset)*2, n);
if (len <0) return(5);

return(0);
}


[2015-01-08 09:11:09] - Creating socket...
[2015-01-08 09:11:09] - Socket successful
[2015-01-13 19:12:11] - Creating socket...
[2015-01-13 19:12:11] - Socket connect failed
[2015-01-13 19:12:11] - Modbus read error
[2015-01-13 19:12:12] - Creating socket...
[2015-01-13 19:12:12] - Socket connect failed
[2015-01-13 19:12:12] - Modbus read error
[2015-01-13 19:12:13] - Creating socket...
[2015-01-13 19:12:13] - Socket connect failed
[2015-01-13 19:12:13] - Modbus read error
[2015-01-13 19:12:14] - Creating socket...
[2015-01-13 19:12:14] - Socket connect failed
[2015-01-13 19:12:14] - Modbus read error
[2015-01-13 19:12:15] - Creating socket...
[2015-01-13 19:12:15] - Socket connect failed
[2015-01-13 19:12:15] - Modbus read error
[2015-01-13 19:12:16] - Creating socket...
[2015-01-13 19:12:16] - Socket connect failed
[2015-01-13 19:12:16] - Modbus read error
[2015-01-13 19:12:17] - Creating socket...
[2015-01-13 19:12:17] - Socket connect failed
[2015-01-13 19:12:17] - Modbus read error
[2015-01-13 19:12:18] - Creating socket...
[2015-01-13 19:12:18] - Socket connect failed
[2015-01-13 19:12:18] - Modbus read error
[2015-01-13 19:12:19] - Creating socket...
6x300W CSUN, ground mount, CL150Lite, 2V/400AhToyo AGM,  Outback VFX3024E, Steca Solarix PL1100
http://www.zoneblue.org/cms/page.php?view=off-grid-solar

dgd

Zb,
Have you tried letting the socket stay connected ?  even just for several  minutes or a fixed repeat count of register set retreivals?
With Libmodbus and Cygwin (*nix system emultor/file system) on W10 compiled with g++ seems to hold the connection for an hour or so but I eventualy get a SOC error and Libmodbus seems to restart the link ( I don't yet quite understand if its a W10 issue or a lib issue or something else)

dgd
Classic 250, 150,  20 140w, 6 250w PVs, 2Kw turbine, MN ac Clipper, Epanel/MNdc, Trace SW3024E (1997), Century 1050Ah 24V FLA (1999). Arduino power monitoring and web server.  Off grid since 4/2000
West Auckland, New Zealand

zoneblue

Up until recently it did stay connected, only breaking the connection when the controller WDT reset. Since 2074 teh resets stopped, and i was able to confirm that the modbus connectuon was watertight. Then i did four seperate manual reboots, one for each combination of the old MNLP, new MNLP, 2074 and 2079. It only started doing this after i fitted the new MNLP with 2079. That might be a coincidence though. Ill keep an eye on it.

I also dont understand Ross modbus read code well enough to say whether that error test for code 4 is actually an fatal error or not.
6x300W CSUN, ground mount, CL150Lite, 2V/400AhToyo AGM,  Outback VFX3024E, Steca Solarix PL1100
http://www.zoneblue.org/cms/page.php?view=off-grid-solar

Westbranch

ZB, do you have access to a MNGP.  Your 4 way test might up a difference with 2079...

off topic, I managed to hit f12 while typing this comment and I see there is a debugger  in the pop up window...  any body know how it works or how to read what shows?
KID FW1811 560W >C&D 24V 900Ah AGM
CL150 29032 FW V.2126-NW2097-GP2133 175A E-Panel WBjr, 3Px4s 140W > 24V 900Ah AGM,
2 Cisco WRT54GL i/c DD-WRT Rtr, NetGr DS104Hub
Cotek ST1500 Inv  want a 24V  ROSIE Inverter
OmniCharge3024  Eu1/2/3000iGens
West Chilcotin 1680+W to come

zoneblue

I dont, but i might order one in my next naws order, just to do some more testing.
6x300W CSUN, ground mount, CL150Lite, 2V/400AhToyo AGM,  Outback VFX3024E, Steca Solarix PL1100
http://www.zoneblue.org/cms/page.php?view=off-grid-solar

zoneblue

This issue has reoccured 10 days after the reboot.  I guess ill try removing the MNLP, and try another reboot.


2016-01-19 15:13:02] - Socket successful
[2016-01-19 15:13:03] - Modbus read error
[2016-01-19 15:13:04] - Creating socket...
[2016-01-19 15:13:04] - Socket successful
[2016-01-19 15:13:05] - Modbus read error
[2016-01-19 15:13:06] - Creating socket...
[2016-01-19 15:13:23] - Socket successful
[2016-01-29 13:57:49] - Modbus read error
[2016-01-29 13:57:50] - Creating socket...
[2016-01-29 13:57:50] - Socket successful
[2016-01-29 13:57:51] - Modbus read error
[2016-01-29 13:57:52] - Creating socket...
[2016-01-29 13:57:52] - Socket successful
[2016-01-29 13:57:53] - Modbus read error
[2016-01-29 13:57:54] - Creating socket...
6x300W CSUN, ground mount, CL150Lite, 2V/400AhToyo AGM,  Outback VFX3024E, Steca Solarix PL1100
http://www.zoneblue.org/cms/page.php?view=off-grid-solar

Westbranch

ZB, it is not exactly the same as the above post...  there is one line missing, in /red...???

2015-01-08 09:11:09] - Creating socket...
[2015-01-08 09:11:09] - Socket successful
[2015-01-13 19:12:11] - Creating socket...
[2015-01-13 19:12:11] - Socket connect failed
[2015-01-13 19:12:11] - Modbus read error
[2015-01-13 19:12:12] - Creating socket...
[2015-01-13 19:12:12] - Socket connect failed
KID FW1811 560W >C&D 24V 900Ah AGM
CL150 29032 FW V.2126-NW2097-GP2133 175A E-Panel WBjr, 3Px4s 140W > 24V 900Ah AGM,
2 Cisco WRT54GL i/c DD-WRT Rtr, NetGr DS104Hub
Cotek ST1500 Inv  want a 24V  ROSIE Inverter
OmniCharge3024  Eu1/2/3000iGens
West Chilcotin 1680+W to come