50 if(len <= 0)
return -1;
51 if(slave < 0)
return -1;
52 if(slave >= 256)
return -1;
57 buf[3] = dbnr & 0x0ff;
58 buf[4] = start_adr / 256;
59 buf[5] = start_adr & 0x0ff;
63 memcpy(&
buf[9],inbuf,len_byte);
70 if(len < 0)
return -1;
72 if(slave < 0)
return -1;
73 if(slave > 255)
return -1;
74 int start_adr = start * 8 + offset;
80 if(len < 0)
return -1;
82 if(slave < 0)
return -1;
83 if(slave > 255)
return -1;
94 if(len_byte < 0)
return -1;
95 if(len_byte >
BUFSIZE)
return -1;
96 if(slave < 0)
return -1;
97 if(slave > 255)
return -1;
100 for(i=0; i<len_byte; i+=4)
103 buf[i+3] = swap.
b[0];
104 buf[i+2] = swap.
b[1];
105 buf[i+1] = swap.
b[2];
111 for(i=0; i<len_byte; i+=4)
115 buf[i+1] = swap.
b[1];
116 buf[i+2] = swap.
b[2];
117 buf[i+3] = swap.
b[3];
130 if(len_byte < 0)
return -1;
131 if(len_byte >
BUFSIZE)
return -1;
132 if(slave < 0)
return -1;
133 if(slave > 255)
return -1;
136 for(i=0; i<len_byte; i+=4)
139 buf[i+3] = swap.
b[0];
140 buf[i+2] = swap.
b[1];
141 buf[i+1] = swap.
b[2];
147 for(i=0; i<len_byte; i+=4)
151 buf[i+1] = swap.
b[1];
152 buf[i+2] = swap.
b[2];
153 buf[i+3] = swap.
b[3];
166 if(len_byte < 0)
return -1;
167 if(len_byte >
BUFSIZE)
return -1;
168 if(slave < 0)
return -1;
169 if(slave > 255)
return -1;
172 for(i=0; i<len_byte; i+=2)
174 swap.
s[0] = val[i/2];
175 buf[i+1] = swap.
b[0];
181 for(i=0; i<len_byte; i+=2)
183 swap.
s[0] = val[i/2];
185 buf[i+1] = swap.
b[1];
198 if(len_byte < 0)
return -1;
199 if(len_byte >
BUFSIZE)
return -1;
200 if(slave < 0)
return -1;
201 if(slave > 255)
return -1;
204 for(i=0; i<len_byte; i+=4)
207 buf[i+3] = swap.
b[0];
208 buf[i+2] = swap.
b[1];
209 buf[i+1] = swap.
b[2];
215 for(i=0; i<len_byte; i+=4)
219 buf[i+1] = swap.
b[1];
220 buf[i+2] = swap.
b[2];
221 buf[i+3] = swap.
b[3];
234 if(len_byte < 0)
return -1;
235 if(len_byte >
BUFSIZE)
return -1;
236 if(slave < 0)
return -1;
237 if(slave > 255)
return -1;
240 for(i=0; i<len_byte; i+=2)
242 swap.
us[0] = val[i/2];
243 buf[i+1] = swap.
b[0];
249 for(i=0; i<len_byte; i+=2)
251 swap.
us[0] = val[i/2];
253 buf[i+1] = swap.
b[1];
267 if(index*4+4 > (
int)
BUFSIZE)
return 0.0
f;
270 swap.
b[0] =
buf[4*index+3];
271 swap.
b[1] =
buf[4*index+2];
272 swap.
b[2] =
buf[4*index+1];
273 swap.
b[3] =
buf[4*index];
277 swap.
b[0] =
buf[4*index];
278 swap.
b[1] =
buf[4*index+1];
279 swap.
b[2] =
buf[4*index+2];
280 swap.
b[3] =
buf[4*index+3];
288 if(index*4+4 > (
int)
BUFSIZE)
return 0;
291 swap.
b[0] =
buf[4*index+3];
292 swap.
b[1] =
buf[4*index+2];
293 swap.
b[2] =
buf[4*index+1];
294 swap.
b[3] =
buf[4*index];
298 swap.
b[0] =
buf[4*index];
299 swap.
b[1] =
buf[4*index+1];
300 swap.
b[2] =
buf[4*index+2];
301 swap.
b[3] =
buf[4*index+3];
309 if(index*2+2 > (
int)
BUFSIZE)
return 0;
312 swap.
b[0] =
buf[2*index+1];
313 swap.
b[1] =
buf[2*index];
317 swap.
b[0] =
buf[2*index];
318 swap.
b[1] =
buf[2*index+1];
326 if(index*4+4 > (
int)
BUFSIZE)
return 0;
329 swap.
b[0] =
buf[4*index+3];
330 swap.
b[1] =
buf[4*index+2];
331 swap.
b[2] =
buf[4*index+1];
332 swap.
b[3] =
buf[4*index];
336 swap.
b[0] =
buf[4*index];
337 swap.
b[1] =
buf[4*index+1];
338 swap.
b[2] =
buf[4*index+2];
339 swap.
b[3] =
buf[4*index+3];
347 if(index*2+4 > (
int)
BUFSIZE)
return 0;
350 swap.
b[0] =
buf[2*index+1];
351 swap.
b[1] =
buf[2*index];
355 swap.
b[0] =
buf[2*index];
356 swap.
b[1] =
buf[2*index+1];
int read(unsigned long offset, void *buf, int len)
int writeByte(int slave, int org, int dbnum, int start, int len, const unsigned char *val)
unsigned int UDword(int index)
int write(int slave, int org, int dbnum, int start, int len, const unsigned char *buf, int function)
int writeUShort(int slave, int org, int dbnum, int start, int len, const unsigned short *val)
int writeFloat(int slave, int org, int dbnum, int start, int len, const float *val)
int writeShort(int slave, int org, int dbnum, int start, int len, const short *val)
int writeDword(int slave, int org, int dbnum, int start, int len, const int *val)
int writeUDword(int slave, int org, int dbnum, int start, int len, const unsigned int *val)
int read(int offset, int len)
rlSiemensTCPClient(const char *mbxname, const char *shmname, int shmsize, int have_to_swap=1)
unsigned int UShort(int index)
virtual ~rlSiemensTCPClient()
int write(const void *buf, int len)
int writeBit(int slave, int org, int dbnum, int start, int offset, int len, const unsigned char *buf)