You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// modbus.h is part of TestModbus-Client.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef _MODBUS_H_
|
|
#define _MODBUS_H_
|
|
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <arpa/inet.h>
|
|
|
|
/*
|
|
* 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_rq_header;
|
|
|
|
|
|
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
|
|
uint8_t number; // number of registers to read
|
|
} typedef modbustcp_res_header;
|
|
|
|
char * modbustcp_pkt_headerrq (char *destbuffer, int bufsize, modbustcp_rq_header *srcmbh);
|
|
char * modbustcp_unpkt_headerrq (modbustcp_rq_header *destmbh, char *srcbuffer, int bufsize);
|
|
|
|
char * modbustcp_pkt_headerres (char *destbuffer, int bufsize, modbustcp_res_header *srcmbh);
|
|
char * modbustcp_unpkt_headerres (modbustcp_res_header *destmbh, char *srcbuffer, int bufsize);
|
|
|
|
|
|
#endif
|