Commit 26209421 authored by Pavel Vainerman's avatar Pavel Vainerman

fixed minor bugs in Modbus

parent 618b749e
......@@ -2,4 +2,4 @@
ulimit -Sc 1000000
uniset-start.sh -f ./uniset-mysql-dbserver --confile test.xml --unideb-add-levels info,crit,warn,level9,system
uniset-start.sh -f ./uniset-mysql-dbserver --confile test.xml --name DBServer --unideb-add-levels info,crit,warn,level9,system
......@@ -48,9 +48,9 @@ MBTCPServer::MBTCPServer( ModbusAddr myaddr, const string inetaddr, int port, bo
sslot->connectRemoteService( sigc::mem_fun(this, &MBTCPServer::remoteService) );
sslot->connectFileTransfer( sigc::mem_fun(this, &MBTCPServer::fileTransfer) );
sslot->setRecvTimeout(2000);
sslot->setRecvTimeout(6000);
// sslot->setAfterSendPause(afterSend);
// sslot->setReplyTimeout(replyTimeout);
sslot->setReplyTimeout(10000);
// build file list...
}
......
......@@ -2,6 +2,12 @@
ulimit -Sc 1000000
uniset-start.sh -f ./uniset-simitator --confile test.xml --sid 10,16
#for i in `seq 1 20`;
#do
uniset-start.sh -f ./uniset-simitator --confile test.xml --sid 10,16
#done
wait
#--unideb-add-levels info,crit,warn,level9,system
......@@ -84,7 +84,7 @@
<RSExchange name="RSExchange" speed="38400">
<DeviceList>
<item addr="0x02" speed="9600" respondSensor="RespondRTU_S" timeout="5000" invert="0"/>
<item addr="0x02" force_disconnect="1" speed="9600" respondSensor="RespondRTU_S" timeout="5000" invert="0"/>
</DeviceList>
</RSExchange>
......@@ -112,7 +112,7 @@
<item name="Input1_S" textname=" 1" node="" iotype="DI" priority="Medium" default="1" />
<item name="Input2_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x04" mbreg="0x02" rs="2" />
<item name="Input3_S" textname=" 3" node="" iotype="DI" priority="Medium"
mbtcp="1" tcp_mbtype="rtu" tcp_mbaddr="0x02" tcp_mbfunc="0x04" tcp_mbreg="0x02"/>
mbtcp="1" tcp_mbtype="rtu" tcp_mbaddr="0x02" tcp_mbfunc="0x06" tcp_mbreg="0x02" tcp_preinit="1" />
<item name="Input4_S" textname=" 4" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x02" mbfunc="0x04" mbreg="0x02" rs="2" />
<item name="Input5_S" textname=" 5" node="" iotype="DI" priority="Medium" udp="2"/>
<item name="Input6_S" textname=" 6" node="" iotype="DI" priority="Medium" udp="2">
......
......@@ -175,8 +175,8 @@ class MBTCPMaster:
enum DeviceType
{
dtUnknown, /*!< */
dtRTU /*!< RTU (default) */
dtUnknown, /*!< */
dtRTU /*!< RTU (default) */
};
static DeviceType getDeviceType( const std::string dtype );
......@@ -189,10 +189,10 @@ class MBTCPMaster:
public IOBase
{
// only for RTU
short nbit; /*!< bit number) */
short nbit; /*!< bit number) */
VTypes::VType vType; /*!< type of value */
short rnum; /*!< count of registers */
short nbyte; /*!< byte number (1-2) */
short rnum; /*!< count of registers */
short nbyte; /*!< byte number (1-2) */
RSProperty():
nbit(-1),vType(VTypes::vtUnknown),
......@@ -213,11 +213,12 @@ class MBTCPMaster:
RegInfo():
mbval(0),mbreg(0),mbfunc(ModbusRTU::fnUnknown),
dev(0),offset(0),
q_num(0),q_count(1)
q_num(0),q_count(1),mb_init(false),sm_init(false),
mb_init_mbreg(0)
{}
ModbusRTU::ModbusData mbval;
ModbusRTU::ModbusData mbreg; /*!< */
ModbusRTU::ModbusData mbreg; /*!< */
ModbusRTU::SlaveFunctionCode mbfunc; /*!< / */
PList slst;
......@@ -226,10 +227,13 @@ class MBTCPMaster:
int offset;
// optimization
int q_num; /*! number in query */
int q_num; /*! number in query */
int q_count; /*! count registers for query */
RegMap::iterator rit;
bool mb_init; /*!< init before use */
bool sm_init; /*!< SM init value */
ModbusRTU::ModbusData mb_init_mbreg; /*!< mb_init register */
};
friend std::ostream& operator<<( std::ostream& os, RegInfo& r );
......@@ -243,8 +247,10 @@ class MBTCPMaster:
resp_id(UniSetTypes::DefaultObjectId),
resp_state(false),
resp_invert(false),
resp_real(true),
resp_init(false)
resp_real(false),
resp_init(false),
ask_every_reg(false),
force_disconnect(false)
{
resp_trTimeout.change(false);
}
......@@ -263,6 +269,8 @@ class MBTCPMaster:
bool resp_invert;
bool resp_real;
bool resp_init;
bool ask_every_reg;
bool force_disconnect;
// return TRUE if state changed
bool checkRespond();
......
......@@ -8,7 +8,7 @@ uniset-start.sh -f ./uniset-mbtcpmaster \
--mbtcp-filter-field mbtcp \
--mbtcp-filter-value 1 \
--mbtcp-gateway-iaddr 127.0.0.1 \
--mbtcp-gateway-port 1024 \
--mbtcp-gateway-port 2048 \
--mbtcp-recv-timeout 5000
#--mbtcp-filter-field mbtcp --mbtcp-filter-value 1
......@@ -1727,7 +1727,7 @@ void RTUExchange::updateRSProperty( RSProperty* p, bool write_only )
IOBase::processingAsDI( p, r->mbval, shm, force );
}
else
IOBase::processingAsAI( p, (unsigned short)(r->mbval), shm, force );
IOBase::processingAsAI( p,r->mbval, shm, force );
}
return;
}
......
......@@ -251,7 +251,7 @@ void IONotifyController::askState( const IOController_i::SensorInfo& si,
smsg.sm_tv_usec = li->second.tv_usec;
}
TransportMessage tm(smsg.transport_msg());
TransportMessage tm(smsg.transport_msg());
try
{
ui.send(ci.id, tm, ci.node);
......@@ -1149,7 +1149,7 @@ void IONotifyController::askOutput(const IOController_i::SensorInfo& si,
smsg.sensor_type = type;
smsg.supplier = getId();
TransportMessage tm(smsg.transport_msg());
TransportMessage tm(smsg.transport_msg());
ui.send(ci.id, tm, ci.node);
}
catch(Exception& ex)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment