Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

45 rader
1.1 KiB

  1. #include "ModbusSlave.h"
  2. CModbusSlave::CModbusSlave(CModbusRepository *Repo) :
  3. CModbusBackend(Repo)
  4. {
  5. mModbusServer = new QTcpServer();
  6. connect(mModbusServer,SIGNAL(newConnection()),this,SLOT(NewModbusConnection()));
  7. mModbusMode = MODBUS_SLAVE_MODE;
  8. }
  9. CModbusSlave::~CModbusSlave()
  10. {
  11. delete mModbusServer;
  12. }
  13. int CModbusSlave::StartSlaveServer(int port)
  14. {
  15. mModbusServer->listen(QHostAddress::Any,port);
  16. qDebug("Slave server started on port %d",port);
  17. return 1;
  18. }
  19. void CModbusSlave::NewModbusConnection()
  20. {
  21. mModbusTCPSocketHandle = mModbusServer->nextPendingConnection();
  22. if(mModbusTCPSocketHandle != 0)
  23. {
  24. mDataLinkValid = true;
  25. connect(mModbusTCPSocketHandle,SIGNAL(readyRead()),this,SLOT(ModbusDataReady()));
  26. connect(mModbusTCPSocketHandle,SIGNAL(disconnected()),this,SLOT(ModbusLinkDisconnected()));
  27. qDebug("Slave: Connection with Master established");
  28. }
  29. }
  30. void CModbusSlave::RegistersDatabaseUpdated(quint16 StartAddress, quint16 Length)
  31. {
  32. }
  33. void CModbusSlave::ModbusRequestException(quint8 ExceptionCode, quint8 FctCode)
  34. {
  35. }