Commit d6db817e authored by Joshua Supra's avatar Joshua Supra
Browse files

added GetIOCfg

parent c5770a77
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
#define PILC_DAC_CH_7 0x7 #define PILC_DAC_CH_7 0x7
#define PILC_DAC_CH_8 0x8 #define PILC_DAC_CH_8 0x8
#define PILC_DAC_CH_9 0x9 #define PILC_DAC_CH_9 0x9
#define PILC_DAC_CH_10 0x10 #define PILC_DAC_CH_10 0xA
#define PILC_DAC_CH_11 0x11 #define PILC_DAC_CH_11 0xB
#define PILC_DAC_CH_12 0x12 #define PILC_DAC_CH_12 0xC
#define PILC_DAC_CH_13 0x13 #define PILC_DAC_CH_13 0xD
#define PILC_DAC_CH_14 0x14 #define PILC_DAC_CH_14 0xE
#define PILC_DAC_CH_15 0x15 #define PILC_DAC_CH_15 0xF
/*************************** Function Prototypes ******************************/ /*************************** Function Prototypes ******************************/
......
...@@ -99,6 +99,7 @@ int FunctionCall(zmq_data *zmq_data_struct){ ...@@ -99,6 +99,7 @@ int FunctionCall(zmq_data *zmq_data_struct){
case SPI_READ: value = PiLC2RSPI(funcArg[0],funcArg[1],zmq_data_struct->socket);break; case SPI_READ: value = PiLC2RSPI(funcArg[0],funcArg[1],zmq_data_struct->socket);break;
case SET_IO_CFG: WriteIOConfig(funcArg);break; case SET_IO_CFG: WriteIOConfig(funcArg);break;
case SET_LOGIC_CFG: setLogicCfg(funcArg[0], funcArg[1]) ;break; case SET_LOGIC_CFG: setLogicCfg(funcArg[0], funcArg[1]) ;break;
case GET_IO_CFG: value = GetIOConfig(zmq_data_struct); ;break;
} }
if(value == 1){ if(value == 1){
//echo the command //echo the command
...@@ -221,7 +222,7 @@ int NetworktoReg(zmq_data *zmq_data_struct){ ...@@ -221,7 +222,7 @@ int NetworktoReg(zmq_data *zmq_data_struct){
unsigned int addr32 = zmq_data_struct->data[1]; unsigned int addr32 = zmq_data_struct->data[1];
//check if address is in range //check if address is in range
status = CheckValidBaseAddr(addr32); status = CheckValidBaseAddr(addr32);
printf("status: %d\n", status);
if (status != 0) { if (status != 0) {
return status; return status;
} }
...@@ -584,3 +585,23 @@ void WriteIOConfig(unsigned int *data) { ...@@ -584,3 +585,23 @@ void WriteIOConfig(unsigned int *data) {
InitIOCards(IOCards); InitIOCards(IOCards);
} }
int GetIOConfig(zmq_data *zmq_data_struct)
{
FILE *fp;
char *buffer;
int filelen;
fp = fopen("/home/suprajos/pilc2/pilc2server/iocfg", "rb");
fseek(fp, 0, SEEK_END);
filelen = ftell(fp);
rewind(fp);
buffer = (char *)malloc(filelen * sizeof(char));
fread(buffer, filelen, 1, fp);
zmq_send (zmq_data_struct->socket, buffer, filelen, 0);
free(buffer);
fclose(fp);
return 0;
}
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#define SPI_READ 0xB #define SPI_READ 0xB
#define SET_IO_CFG 0xC #define SET_IO_CFG 0xC
#define SET_LOGIC_CFG 0xD #define SET_LOGIC_CFG 0xD
#define GET_IO_CFG 0xF
typedef struct { typedef struct {
void *socket; void *socket;
...@@ -52,6 +53,7 @@ int PiLC2RSPI(unsigned int card, unsigned int reg, void *socket); ...@@ -52,6 +53,7 @@ int PiLC2RSPI(unsigned int card, unsigned int reg, void *socket);
void PiLC2WSPI(unsigned int card, unsigned int reg, unsigned int data); void PiLC2WSPI(unsigned int card, unsigned int reg, unsigned int data);
void PiLC2InitIOCards(void); void PiLC2InitIOCards(void);
void WriteIOConfig(unsigned int *data); void WriteIOConfig(unsigned int *data);
int GetIOConfig(zmq_data *zmq_data_struct);
void *context; void *context;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment