45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
#include "ModbusSlave.h"
|
|
|
|
|
|
CModbusSlave::CModbusSlave(CModbusRepository *Repo) :
|
|
CModbusBackend(Repo)
|
|
{
|
|
mModbusServer = new QTcpServer();
|
|
connect(mModbusServer,SIGNAL(newConnection()),this,SLOT(NewModbusConnection()));
|
|
mModbusMode = MODBUS_SLAVE_MODE;
|
|
}
|
|
|
|
CModbusSlave::~CModbusSlave()
|
|
{
|
|
delete mModbusServer;
|
|
}
|
|
|
|
int CModbusSlave::StartSlaveServer(int port)
|
|
{
|
|
mModbusServer->listen(QHostAddress::Any,port);
|
|
qDebug("Slave server started on port %d",port);
|
|
return 1;
|
|
}
|
|
|
|
void CModbusSlave::NewModbusConnection()
|
|
{
|
|
mModbusTCPSocketHandle = mModbusServer->nextPendingConnection();
|
|
if(mModbusTCPSocketHandle != 0)
|
|
{
|
|
mDataLinkValid = true;
|
|
connect(mModbusTCPSocketHandle,SIGNAL(readyRead()),this,SLOT(ModbusDataReady()));
|
|
connect(mModbusTCPSocketHandle,SIGNAL(disconnected()),this,SLOT(ModbusLinkDisconnected()));
|
|
qDebug("Slave: Connection with Master established");
|
|
}
|
|
}
|
|
|
|
void CModbusSlave::RegistersDatabaseUpdated(quint16 StartAddress, quint16 Length)
|
|
{
|
|
|
|
}
|
|
|
|
void CModbusSlave::ModbusRequestException(quint8 ExceptionCode, quint8 FctCode)
|
|
{
|
|
|
|
}
|