29 unsigned char buf[512];
32 if(datalen < 0)
return -1;
33 if(datalen > 256)
return -1;
34 if(slave < 0)
return -1;
35 if(slave > 255)
return -1;
36 if(
function < 0)
return -1;
39 for(i=0; i<datalen; i++)
49 unsigned char data[8];
51 data[0] = adr/256; data[1] = adr & 0x0ff;
52 data[2] = 0; data[3] = 0;
53 if(value != 0) data[2] = 0x0ff;
59 unsigned char data[512];
62 if(num_coils <= 0)
return -1;
63 byte_count = ((num_coils-1)/8) + 1;
64 data[0] = adr/256; data[1] = adr & 0x0ff;
65 data[2] = num_coils/256; data[3] = num_coils & 0x0ff;
67 for(i=0; i<byte_count; i++)
69 if((5+i) > (int)
sizeof(data))
return -1;
70 data[5+i] = values[i];
77 unsigned char data[8];
79 data[0] = adr/256; data[1] = adr & 0x0ff;
80 data[2] = value/256; data[3] = value & 0x0ff;
86 unsigned char data[512];
89 data[0] = adr/256; data[1] = adr & 0x0ff;
90 data[2] = num_values/256; data[3] = num_values & 0x0ff;
91 data[4] = num_values*2;
92 for(i=0; i<num_values; i++)
94 if((5+i*2) > (
int)
sizeof(data))
return -1;
95 data[5+i*2] = values[i]/256; data[6+i*2] = values[i] & 0x0ff;
103 unsigned char buf[128+1],b;
105 if(number < 0)
return -1;
106 if(number > 128)
return -1;
138 if(ret > 0)
return 1;
144 unsigned char buf[4],b;
146 if(number < 0)
return -1;
147 if(number > 128)
return -1;
155 unsigned char buf[4];
158 if(number < 0)
return -1;
159 if(number > 64)
return -1;
161 s = buf[0]*256 + buf[1];
int read(unsigned long offset, void *buf, int len)
int writePresetMultipleRegisters(int slave, int adr, const int *values, int num_values)
int writeMultipleCoils(int slave, int adr, const unsigned char *values, int num_coils)
int writeSingleCoil(int slave, int adr, int value)
virtual ~rlModbusClient()
int readByte(int offset, int number)
int readBit(int offset, int number)
int write(int slave, int function, const unsigned char *data, int len)
int readShort(int offset, int number)
int writePresetSingleRegister(int slave, int adr, int value)
int write(const void *buf, int len)
rlModbusClient(const char *mbxname, const char *shmname, int shmsize)