Communication for solid slow control.
Fork of sscm_comm by
Revision 5:357fa8928d63, committed 2014-10-02
- Comitter:
- wbeaumont
- Date:
- Thu Oct 02 10:47:18 2014 +0000
- Parent:
- 4:66d1a4200f67
- Child:
- 6:d9a96735d0fb
- Commit message:
- changed to u16 format for datain dataout
Changed in this revision
sscm_comm.cpp | Show annotated file Show diff for this revision Revisions of this file |
sscm_comm.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/sscm_comm.cpp Tue Sep 30 13:19:31 2014 +0000 +++ b/sscm_comm.cpp Thu Oct 02 10:47:18 2014 +0000 @@ -8,7 +8,7 @@ #include "sscm_comm.h" -#define SSCM_LIB_SRC_VERSION "1.40" +#define SSCM_LIB_SRC_VERSION "2.00" using namespace sscm_comm; @@ -19,7 +19,7 @@ part[0]=input[0];part[1]=input[1];part[2]=0;sc->module = (u8)strtol(part, NULL, 16); if( input[3] != SEP ) rv =-1; // tbd check for module range else { - u32 ic;//input counter + u16 ic;//input counter part[0]=input[4];part[1]=input[5];part[2]=0;sc->con = (u8)strtol(part, NULL, 16); if( input[6] != SEP ) rv= -2; // tbd check for connector range else { @@ -36,10 +36,10 @@ part[0]=input[ic++];part[1]=input[ic++];part[2]=0;sc->ch = (u8)strtol(part, NULL, 16); if( input[ic++] != SEP ) rv= -5; else{ - part[0]=input[ic++];part[1]=input[ic++];part[2]=input[ic++];part[3]=input[ic++];part[4]=0;sc->datain = (u32)strtol(part, NULL, 16); + part[0]=input[ic++];part[1]=input[ic++];part[2]=input[ic++];part[3]=input[ic++];part[4]=0;sc->datain = (u16)strtol(part, NULL, 16); if( input[ic++] != SEP ) rv= -6; else { - part[0]=input[ic++];part[1]=input[ic++];part[2]=input[ic++];part[3]=input[ic++];part[4]=0;sc->dataout = (u32)strtol(part, NULL, 16); + part[0]=input[ic++];part[1]=input[ic++];part[2]=input[ic++];part[3]=input[ic++];part[4]=0;sc->dataout = (u16)strtol(part, NULL, 16); if( input[ic++] != SEP ) rv= -7; else { part[0]=input[ic++];part[1]=input[ic++];part[4]=0;sc->status = (u8)strtol(part, NULL, 16);
--- a/sscm_comm.h Tue Sep 30 13:19:31 2014 +0000 +++ b/sscm_comm.h Thu Oct 02 10:47:18 2014 +0000 @@ -1,13 +1,14 @@ #ifndef SSCM_COMM_H #define SSCM_COMM_H /* - * v 1.01 inital published , tested - * v 1.20 added devnr, added range checking - * v 1.30 added \0 to cmd field - * v 1.40 added status in cmd , added SSCM as device + * v 1.01 inital published , tested + * v 1.20 added devnr, added range checking + * v 1.30 added \0 to cmd field + * v 1.40 added status in cmd , added SSCM as device + * v 2.00 corrected the type for data in data out */ -#define SSCM_COMM_LIB_HDR_VERSION "1.40" +#define SSCM_COMM_LIB_HDR_VERSION "2.00" #define MAXCMDLLENGTH 256 @@ -16,7 +17,7 @@ enum ssc_dev{ ADC=1, DAC=2, TEMP=3,SSCCM=4}; typedef unsigned char u8; -typedef unsigned int u32; +typedef unsigned short u16; typedef struct { u8 module; // 1 char 0 --F u8 con; // 1 char 0--2 @@ -24,8 +25,8 @@ u8 devnr; char cmd[5]; // 5 char + \0 u8 ch; // 2 char 00 -- FF or register nr - u32 datain; // 2 char 0000 -- FFFF - u32 dataout;// 2 char 00 -- FF + u16 datain; // 2 char 0000 -- FFFF + u16 dataout;// 2 char 00 -- FF u8 status; } ssc_cmd;