41 int rlPPIClient::write(
int slave,
int area,
int dbnum,
int start,
int len,
const unsigned char *data)
45 if(len < 0)
return -1;
47 if(slave < 0)
return -1;
48 if(slave > 31)
return -1;
53 buf[3] = dbnum & 0x0ff;
55 buf[5] = start & 0x0ff;
58 memcpy(&
buf[8],data,len);
69 if(len < 0)
return -1;
71 if(slave < 0)
return -1;
72 if(slave > 31)
return -1;
95 return write(slave,area,dbnum,start,len,
buf);
104 if(len < 0)
return -1;
106 if(slave < 0)
return -1;
107 if(slave > 31)
return -1;
110 for(i=0; i<len; i+=4)
113 buf[i+3] = swap.
b[0];
114 buf[i+2] = swap.
b[1];
115 buf[i+1] = swap.
b[2];
121 for(i=0; i<len; i+=4)
125 buf[i+1] = swap.
b[1];
126 buf[i+2] = swap.
b[2];
127 buf[i+3] = swap.
b[3];
130 return write(slave,area,dbnum,start,len,
buf);
139 if(len < 0)
return -1;
141 if(slave < 0)
return -1;
142 if(slave > 31)
return -1;
145 for(i=0; i<len; i+=2)
147 swap.
s[0] = val[i/2];
148 buf[i+1] = swap.
b[0];
154 for(i=0; i<len; i+=2)
156 swap.
s[0] = val[i/2];
158 buf[i+1] = swap.
b[1];
161 return write(slave,area,dbnum,start,len,
buf);
170 if(len < 0)
return -1;
172 if(slave < 0)
return -1;
173 if(slave > 31)
return -1;
176 for(i=0; i<len; i+=4)
179 buf[i+3] = swap.
b[0];
180 buf[i+2] = swap.
b[1];
181 buf[i+1] = swap.
b[2];
187 for(i=0; i<len; i+=4)
191 buf[i+1] = swap.
b[1];
192 buf[i+2] = swap.
b[2];
193 buf[i+3] = swap.
b[3];
196 return write(slave,area,dbnum,start,len,
buf);
205 if(len < 0)
return -1;
207 if(slave < 0)
return -1;
208 if(slave > 31)
return -1;
211 for(i=0; i<len; i+=2)
213 swap.
us[0] = val[i/2];
214 buf[i+1] = swap.
b[0];
220 for(i=0; i<len; i+=2)
222 swap.
us[0] = val[i/2];
224 buf[i+1] = swap.
b[1];
227 return write(slave,area,dbnum,start,len,
buf);
238 if(index*4+4 > (
int)
BUFSIZE)
return 0.0
f;
241 swap.
b[0] =
buf[4*index+3];
242 swap.
b[1] =
buf[4*index+2];
243 swap.
b[2] =
buf[4*index+1];
244 swap.
b[3] =
buf[4*index];
248 swap.
b[0] =
buf[4*index];
249 swap.
b[1] =
buf[4*index+1];
250 swap.
b[2] =
buf[4*index+2];
251 swap.
b[3] =
buf[4*index+3];
259 if(index*4+4 > (
int)
BUFSIZE)
return 0;
262 swap.
b[0] =
buf[4*index+3];
263 swap.
b[1] =
buf[4*index+2];
264 swap.
b[2] =
buf[4*index+1];
265 swap.
b[3] =
buf[4*index];
269 swap.
b[0] =
buf[4*index];
270 swap.
b[1] =
buf[4*index+1];
271 swap.
b[2] =
buf[4*index+2];
272 swap.
b[3] =
buf[4*index+3];
280 if(index*2+2 > (
int)
BUFSIZE)
return 0;
283 swap.
b[0] =
buf[2*index+1];
284 swap.
b[1] =
buf[2*index];
288 swap.
b[0] =
buf[4*index];
289 swap.
b[1] =
buf[4*index+1];
297 if(index*4+4 > (
int)
BUFSIZE)
return 0;
300 swap.
b[0] =
buf[4*index+3];
301 swap.
b[1] =
buf[4*index+2];
302 swap.
b[2] =
buf[4*index+1];
303 swap.
b[3] =
buf[4*index];
307 swap.
b[0] =
buf[4*index];
308 swap.
b[1] =
buf[4*index+1];
309 swap.
b[2] =
buf[4*index+2];
310 swap.
b[3] =
buf[4*index+3];
318 if(index*2+4 > (
int)
BUFSIZE)
return 0;
321 swap.
b[0] =
buf[2*index+1];
322 swap.
b[1] =
buf[2*index];
326 swap.
b[0] =
buf[4*index];
327 swap.
b[1] =
buf[4*index+1];
int read(unsigned long offset, void *buf, int len)
int writeUShort(int slave, int area, int dbnum, int start, int len, const unsigned short *val)
rlPPIClient(const char *mbxname, const char *shmname, int shmsize, int have_to_swap=1)
int writeShort(int slave, int area, int dbnum, int start, int len, const short *val)
int writeFloat(int slave, int area, int dbnum, int start, int len, const float *val)
int writeUDword(int slave, int area, int dbnum, int start, int len, const unsigned int *val)
int read(int offset, int len)
unsigned int UShort(int index)
int write(int slave, int area, int dbnum, int start, int len, const unsigned char *data)
unsigned int UDword(int index)
int writeDword(int slave, int area, int dbnum, int start, int len, const int *val)
int write(const void *buf, int len)