versadac  1
versadac - Scalable Recorder Firmware
mb_serial.h
1 /*****************************************************************************
2 FILE : mb_serial.h
3 AUTHOR : Karl Wakeham
4 SYSTEM : Diab comiler for ARM
5 DESCRIPTION : Serial modbus comms driver class declarations
6 *****************************************************************************/
7 
8 #ifndef __MBSDRIVER_H
9 #define __MBSDRIVER_H
10 
11 #include <stdio.h>
12 #include "OSTask.h"
13 #include "stdtypes.h"
14 
15 #define MAX_MODBUS_MESSAGE_SIZE 280
16 #define DEBUG_SCOMMS 1
17 
18 class MB_Serial : public OSRunnableTask
19 {
20  public:
21 
22  MB_Serial();
23 
24  virtual ~MB_Serial();
25 
26  uint16 calcCrc(uint8 *z_pBuf, uint16 z_msgLength);
27  void runTask();
28  void stop();
29  void initialiseSerialComms();
30  void createReplyHeader(void);
31  void createException(uint8 error_code);
32  void sendExchangeMessage(exchange_id xid, uint32 *pMsg);
33  uint8 getExchangeMessage(exchange_id xid, uint32 *pMsg);
34 
35  private:
36  void log(char * z_msg, uint8 * z_arg1 = NULL);
37 
38  uint16 m_rxCharCount;
39  uint16 m_txCharCount;
40  uint8 m_rxMessageBuf[MAX_MODBUS_MESSAGE_SIZE];
41  uint8 m_txMessageBuf[MAX_MODBUS_MESSAGE_SIZE];
42  uint8 m_modbusAddress;
43  uint16 m_numberOfGroups;
44  sint32 m_socketFileDesc;
45  BOOL m_serialCommsInitialised;
46  uint8 m_protocol;
47  exchange_id m_c_mbXid; //connection exchange id
48  exchange_id m_s_mbXid0; // serial connection 1exchange id
49 
50 };
51 
52 #endif
53 
Definition: ostask.h:16
Definition: stdtypes.h:213
Definition: mb_serial.h:18