- Changed strncpy to strlcpy, strncat to strlcat
- Added strlcpy and strlcat to SICS - Added a driver for the POLDI power supplies
This commit is contained in:
21
slsecho.c
21
slsecho.c
@ -15,6 +15,9 @@
|
||||
* with mode being either r or w and convertflag being one of
|
||||
* none,read,write
|
||||
*
|
||||
* There is an endianness issue here: swapDataBytes may or not be
|
||||
* required according to the platform used.
|
||||
*
|
||||
* Created on: Mar 18, 2010
|
||||
* Author: Mark Koennecke
|
||||
*/
|
||||
@ -95,7 +98,18 @@ static double DSPfloat2double(ULONG input)
|
||||
}
|
||||
return output;
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static void swapDataBytes(char *pMessage)
|
||||
{
|
||||
char tmp[4];
|
||||
|
||||
memcpy(tmp,pMessage+4,4);
|
||||
pMessage[4] = tmp[3];
|
||||
pMessage[5] = tmp[2];
|
||||
pMessage[6] = tmp[1];
|
||||
pMessage[7] = tmp[0];
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int EchoPack(Ascon *a)
|
||||
{
|
||||
pSLSEcho echo = NULL;
|
||||
@ -161,6 +175,7 @@ static int EchoPack(Ascon *a)
|
||||
val = double2DSPfloat(dval);
|
||||
}
|
||||
memcpy(pMessage+4,&val,4);
|
||||
swapDataBytes(pMessage);
|
||||
|
||||
/* printf("Sending code: 0x%x, val = %d\n", code, val); */
|
||||
return 1;
|
||||
@ -170,7 +185,8 @@ static int EchoUnpack(Ascon *a)
|
||||
{
|
||||
pSLSEcho echo = a->private;
|
||||
char *pMessage = NULL, printbuf[30];
|
||||
int code, val;
|
||||
int val;
|
||||
unsigned char code = 0;
|
||||
double dval;
|
||||
|
||||
|
||||
@ -182,6 +198,7 @@ static int EchoUnpack(Ascon *a)
|
||||
DynStringConcat(a->rdBuffer,printbuf);
|
||||
DynStringConcatChar(a->rdBuffer,':');
|
||||
|
||||
swapDataBytes(pMessage);
|
||||
memcpy(&val,pMessage+4, 4);
|
||||
dval = (double)val;
|
||||
|
||||
|
Reference in New Issue
Block a user