///////////////////////////////////////////////////////////////////////////////// // // modbus.h is part of TestModbus-Client. // ///////////////////////////////////////////////////////////////////////////////// #ifndef _MODBUS_H_ #define _MODBUS_H_ #include #include #include /* * this file will only contain the encoding and decoding functions */ struct { uint16_t transid; // transaction id uint16_t protid; // protocol id uint16_t length; // number of bytes followed uint8_t uid; // unit/slave id uint8_t fc; // function code uint16_t offset; // first register to read uint16_t number; // number of registers to read } typedef modbustcp_header; char * modbustcp_pkt_header (char *destbuffer, int bufsize, modbustcp_header *srcmbh); char * modbustcp_unpkt_header (modbustcp_header *destmbh, char *srcbuffer, int bufsize); #endif