Commit 3d5d683d authored by Pavel Vaynerman's avatar Pavel Vaynerman

merge with ComPort

minor fixes in MBTCPMaster
parent 635c96f5
......@@ -100,9 +100,9 @@ int main( int argc, char **argv )
{
ComPort485F* cp;
if( dev == "/dev/ttyS2" )
cp = new ComPort485F(dev,5,false);
cp = new ComPort485F(dev,5);
else if( dev == "/dev/ttyS3" )
cp = new ComPort485F(dev,6,false);
cp = new ComPort485F(dev,6);
else
{
cerr << "dev must be /dev/ttyS2 or /dev/tytS3" << endl;
......
......@@ -3,7 +3,7 @@
Name: libuniset
Version: 0.97
Release: eter16
Release: eter19
Summary: UniSet - library for building distributed industrial control systems
License: GPL
Group: Development/C++
......@@ -178,6 +178,15 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Mon Sep 28 2009 Pavel Vainerman <pv@etersoft.ru> 0.97-eter18
- restore mutex
* Mon Sep 28 2009 Pavel Vainerman <pv@etersoft.ru> 0.97-eter17
- new mbtcpmaster
* Mon Sep 28 2009 Pavel Vainerman <pv@etersoft.ru> 0.97-eter16
- new mutex
* Sat Sep 26 2009 Pavel Vainerman <pv@altlinux.ru> 0.97-eter15
- new build
......
......@@ -1539,10 +1539,25 @@ void MBTCPMaster::updateRSProperty( RSProperty* p, bool write_only )
if( p->rnum <= 1 )
{
if( save )
{
if( p->stype == UniversalIO::DigitalInput ||
p->stype == UniversalIO::DigitalOutput )
{
r->mbval = IOBase::processingAsDO( p, shm, force_out );
}
else
r->mbval = IOBase::processingAsAO( p, shm, force_out );
}
else
{
if( p->stype == UniversalIO::DigitalInput ||
p->stype == UniversalIO::DigitalOutput )
{
IOBase::processingAsDI( p, r->mbval, shm, force );
}
else
IOBase::processingAsAI( p, r->mbval, shm, force );
}
return;
}
......
......@@ -108,7 +108,7 @@ prefix(prefix)
throw UniSetTypes::SystemError(myname+"(MBSlave): Unknown slave type. Use: --mbs-type [RTU|TCP]");
// mbslot->connectReadCoil( sigc::mem_fun(this, &MBSlave::readCoilStatus) );
// mbslot->connectReadInputStatus( sigc::mem_fun(this, &MBSlave::readInputStatus) );
mbslot->connectReadInputStatus( sigc::mem_fun(this, &MBSlave::readInputStatus) );
mbslot->connectReadOutput( sigc::mem_fun(this, &MBSlave::readOutputRegisters) );
mbslot->connectReadInput( sigc::mem_fun(this, &MBSlave::readInputRegisters) );
// mbslot->connectForceSingleCoil( sigc::mem_fun(this, &MBSlave::forceSingleCoil) );
......@@ -1138,8 +1138,74 @@ ModbusRTU::mbErrCode MBSlave::readCoilStatus( ReadCoilMessage& query,
ModbusRTU::mbErrCode MBSlave::readInputStatus( ReadInputStatusMessage& query,
ReadInputStatusRetMessage& reply )
{
// cout << "(readInputStatus): " << query << endl;
return ModbusRTU::erOperationFailed;
if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << myname << "(readInputStatus): " << query << endl;
try
{
if( query.count <= 1 )
{
ModbusRTU::ModbusData d = 0;
ModbusRTU::mbErrCode ret = real_read(query.start,d);
if( ret == ModbusRTU::erNoError )
reply.addData(d);
else
reply.addData(0);
pingOK = true;
return ret;
}
// :
int num=0; //
ModbusRTU::ModbusData d = 0;
ModbusRTU::ModbusData reg = query.start;
for( ; num<query.count; num++, reg++ )
{
ModbusRTU::mbErrCode ret = real_read(reg,d);
if( ret == ModbusRTU::erNoError )
reply.addData(d);
else
reply.addData(0);
}
// , ۣ
// ...
// if( reply.bcnt < query.count )
// {
// dlog[Debug::WARN] << myname
// << "(readInputStatus): query.count=" << query.count
// << " > reply.count=" << reply.count << endl;
// }
pingOK = true;
return ModbusRTU::erNoError;
}
catch( UniSetTypes::NameNotFound& ex )
{
dlog[Debug::WARN] << myname << "(readInputStatus): " << ex << endl;
return ModbusRTU::erBadDataAddress;
}
catch( Exception& ex )
{
if( pingOK )
dlog[Debug::CRIT] << myname << "(readInputStatus): " << ex << endl;
}
catch( CORBA::SystemException& ex )
{
if( pingOK )
dlog[Debug::CRIT] << myname << "(readInputStatus): ORBA::SystemException: "
<< ex.NP_minorString() << endl;
}
catch(...)
{
if( pingOK )
dlog[Debug::CRIT] << myname << "(readInputStatus): catch ..." << endl;
}
pingOK = false;
return ModbusRTU::erTimeOut;
}
// -------------------------------------------------------------------------
ModbusRTU::mbErrCode MBSlave::forceMultipleCoils( ModbusRTU::ForceCoilsMessage& query,
......
......@@ -21,7 +21,7 @@ class ComPort485F:
{
public:
ComPort485F( std::string comDevice, int gpio_num, bool tmit_ctrl );
ComPort485F( std::string comDevice, int gpio_num, bool tmit_ctrl=false );
virtual void sendByte( unsigned char x );
virtual void setTimeout( int timeout );
......
......@@ -21,9 +21,9 @@ ModbusRTUMaster::ModbusRTUMaster( const string dev, bool use485 ):
{
ComPort485F* cp;
if( dev == "/dev/ttyS2" )
cp = new ComPort485F(dev,5,false);
cp = new ComPort485F(dev,5);
else if( dev == "/dev/ttyS3" )
cp = new ComPort485F(dev,6,false);
cp = new ComPort485F(dev,6);
else
throw Exception("Open ComPort FAILED! dev must be /dev/ttyS2 or /dev/tytS3");
......
......@@ -21,9 +21,9 @@ ModbusRTUSlave::ModbusRTUSlave( const string dev, bool use485 ):
{
ComPort485F* cp;
if( dev == "/dev/ttyS2" )
cp = new ComPort485F(dev,5,false);
cp = new ComPort485F(dev,5);
else if( dev == "/dev/ttyS3" )
cp = new ComPort485F(dev,6,false);
cp = new ComPort485F(dev,6);
else
throw Exception("Open ComPort FAILED! dev must be /dev/ttyS2 or /dev/tytS3");
......
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