Host code for alert

This commit is contained in:
swateeshrivastava
2018-11-29 16:38:08 +05:30
parent 24e7a02e8c
commit 04bed94c8e
38 changed files with 38588 additions and 1774 deletions

View File

@@ -228,6 +228,15 @@ SCHEMA_IMPORT bool TestMod_cmdReset(void *driver, void *params);
SCHEMA_IMPORT bool obc_pre_init(void *driver, void *returnValue);
SCHEMA_IMPORT bool SYS_post_get_results(void **getpostResult);
SCHEMA_IMPORT bool SYS_post_enable(void **postActivate);
SCHEMA_IMPORT bool sys_alert_log(void *driver, void *params);
SCHEMA_IMPORT bool power_alert_log(void *driver, void *params);
SCHEMA_IMPORT bool bms_alert_log(void *driver, void *params);
SCHEMA_IMPORT bool hci_alert_log(void *driver, void *params);
SCHEMA_IMPORT bool eth_alert_log(void *driver, void *params);
SCHEMA_IMPORT bool gpp_alert_log(void *driver, void *params);
SCHEMA_IMPORT bool sdr_alert_log(void *driver, void *params);
SCHEMA_IMPORT bool rffe_alert_log(void *driver, void *params);
SCHEMA_IMPORT bool sync_alert_log(void *driver, void *params);
const Component sys_schema[] = {
{
@@ -268,6 +277,11 @@ const Component sys_schema[] = {
.name = "echo",
.cb_cmd = SYS_cmdEcho,
},
{
.name = "getAlertLogs",
.cb_cmd = sys_alert_log,
},
{} },
},
{} },
@@ -292,6 +306,11 @@ const Component sys_schema[] = {
.postDisabled = POST_DISABLED,
},
{} },
.commands = (Command[]){ {
.name = "getAlertLogs",
.cb_cmd = power_alert_log,
},
{} },
},
{ .name = "leadacid_sensor",
.components =
@@ -340,6 +359,13 @@ const Component sys_schema[] = {
{
.name = "comp_all",
.postDisabled = POST_DISABLED,
.commands =
(Command[]){
{
.name = "getAlertLogs",
.cb_cmd = bms_alert_log,
},
{} },
},
{ .name = "ec",
.components =
@@ -377,6 +403,13 @@ const Component sys_schema[] = {
{
.name = "comp_all",
.postDisabled = POST_DISABLED,
.commands =
(Command[]){
{
.name = "getAlertLogs",
.cb_cmd = hci_alert_log,
},
{} },
},
{
.name = "led",
@@ -407,36 +440,43 @@ const Component sys_schema[] = {
},
{
.name = "ethernet",
.components = (Component[]){ {
.name = "comp_all",
.postDisabled = POST_DISABLED,
},
{
.name = "port0",
.driver = &ETH_SW,
.driver_cfg = &gbc_eth_port0,
},
{
.name = "port1",
.driver = &ETH_SW,
.driver_cfg = &gbc_eth_port1,
},
{
.name = "port2",
.driver = &ETH_SW,
.driver_cfg = &gbc_eth_port2,
},
{
.name = "port3",
.driver = &ETH_SW,
.driver_cfg = &gbc_eth_port3,
},
{
.name = "port4",
.driver = &ETH_SW,
.driver_cfg = &gbc_eth_port4,
},
{} },
.components =
(Component[]){ {
.name = "comp_all",
.postDisabled = POST_DISABLED,
.commands =
(Command[]){ {
.name = "getAlertLogs",
.cb_cmd = eth_alert_log,
},
{} },
},
{
.name = "port0",
.driver = &ETH_SW,
.driver_cfg = &gbc_eth_port0,
},
{
.name = "port1",
.driver = &ETH_SW,
.driver_cfg = &gbc_eth_port1,
},
{
.name = "port2",
.driver = &ETH_SW,
.driver_cfg = &gbc_eth_port2,
},
{
.name = "port3",
.driver = &ETH_SW,
.driver_cfg = &gbc_eth_port3,
},
{
.name = "port4",
.driver = &ETH_SW,
.driver_cfg = &gbc_eth_port4,
},
{} },
},
{
.name = "obc",
@@ -464,6 +504,13 @@ const Component sys_schema[] = {
{
.name = "comp_all",
.postDisabled = POST_DISABLED,
.commands =
(Command[]){
{
.name = "getAlertLogs",
.cb_cmd = gpp_alert_log,
},
{} },
},
{
@@ -579,6 +626,10 @@ const Component sys_schema[] = {
.name = "reset",
.cb_cmd = SDR_fx3Reset,
},
{
.name = "getAlertLogs",
.cb_cmd = sdr_alert_log,
},
{} },
.postDisabled = POST_DISABLED,
},
@@ -609,6 +660,11 @@ const Component sys_schema[] = {
.name = "reset",
.cb_cmd = RFFE_reset,
},
{
.name = "getAlertLogs",
.cb_cmd = rffe_alert_log,
},
{} },
},
{ .name = "ch1_sensor",
@@ -762,11 +818,16 @@ const Component sys_schema[] = {
(Component[]){ {
.name = "comp_all",
.driver_cfg = &sync_gpiocfg,
.commands = (Command[]){ {
.name = "reset",
.cb_cmd = SYNC_reset,
},
{} },
.commands =
(Command[]){ {
.name = "reset",
.cb_cmd = SYNC_reset,
},
{
.name = "getAlertLogs",
.cb_cmd = sync_alert_log,
},
{} },
.postDisabled = POST_DISABLED,
},
{

View File

@@ -41,7 +41,7 @@ ocware_stub: $(OBJECTS)
$(CC) $(src_ocware_stub) -o $(output_dir)/ocware_stub $(LIBS) $(CFLAGS) -DOCWARE_HOST
occli: $(OBJECTS)
$(CC) $(src_occli) -o $(output_dir)/occli $(LIBS) $(CFLAGS) -DOCWARE_HOST
$(CC) $(src_occli) -o $(output_dir)/occli $(LIBS) $(CFLAGS) -DOCWARE_HOST -DOCCLI_LOG
ln -sf occli $(output_dir)/occmd

View File

@@ -12,44 +12,66 @@
#include <syslog.h>
#include <libgen.h>
#define __filename__ (basename(__FILE__))
#define __filename__ (basename(__FILE__))
#ifdef CONSOLE_LOG
#define logit(facility, fmt, ...) \
{ \
if(facility != LOG_DEBUG) \
printf(fmt "\n", ##__VA_ARGS__); \
else \
printf ("[%s:%d, %s()]:" fmt "\n", __filename__, \
__LINE__, __func__, ##__VA_ARGS__); \
}
#else /* syslog */
#define logit(facility, fmt, ...) \
{ \
if(facility != LOG_DEBUG) \
syslog(facility, fmt "\n", ##__VA_ARGS__); \
else \
syslog(facility, "<d> [%s:%d, %s()]: " fmt "\n", \
__filename__, __LINE__, __func__, ##__VA_ARGS__); \
}
# define logit(facility, fmt, ...) \
{ \
if (facility != LOG_DEBUG) \
printf(fmt "\n", ##__VA_ARGS__); \
else \
printf("[%s:%d, %s()]:" fmt "\n", __filename__, __LINE__, \
__func__, ##__VA_ARGS__); \
}
#elif SYS_LOG /* syslog */
# define logit(facility, fmt, ...) \
{ \
if (facility != LOG_DEBUG) \
syslog(facility, fmt "\n", ##__VA_ARGS__); \
else \
syslog(facility, "<d> [%s:%d, %s()]: " fmt "\n", __filename__, \
__LINE__, __func__, ##__VA_ARGS__); \
}
#elif OCCLI_LOG
# define logit(facility, fmt, ...) \
{ \
FILE *fp; \
fp = fopen("./log/logFileOccli.txt", "a"); \
if (facility != LOG_DEBUG) \
fprintf(fp, fmt "\n", ##__VA_ARGS__); \
else \
fprintf(fp, "[%s:%d, %s()]:" fmt "\n", __filename__, __LINE__, \
__func__, ##__VA_ARGS__); \
fclose(fp); \
}
#else
# define logit(facility, fmt, ...) \
{ \
FILE *fp; \
fp = fopen("./log/logFileMW.txt", "a"); \
if (facility != LOG_DEBUG) \
fprintf(fp, fmt "\n", ##__VA_ARGS__); \
else \
fprintf(fp, "[%s:%d, %s()]:" fmt "\n", __filename__, __LINE__, \
__func__, ##__VA_ARGS__); \
fclose(fp); \
}
#endif
#define logemerg(fmt, ...) logit(LOG_EMERG, "<E> " fmt, ##__VA_ARGS__)
#define logalert(fmt, ...) logit(LOG_ALERT, "<A> " fmt, ##__VA_ARGS__)
#define logcrit(fmt, ...) logit(LOG_CRIT, "<C> " fmt, ##__VA_ARGS__)
#define logerr(fmt, ...) logit(LOG_ERR, "<e> " fmt, ##__VA_ARGS__)
#define logwarn(fmt, ...) logit(LOG_WARNING, "<w> " fmt, ##__VA_ARGS__)
#define lognotice(fmt, ...) logit(LOG_NOTICE, "<n> " fmt, ##__VA_ARGS__)
#define loginfo(fmt, ...) logit(LOG_INFO, "<i> " fmt, ##__VA_ARGS__)
#define logdebug(fmt, ...) logit(LOG_DEBUG, fmt, ##__VA_ARGS__)
#define logemerg(fmt, ...) logit(LOG_EMERG, "<E> " fmt, ##__VA_ARGS__)
#define logalert(fmt, ...) logit(LOG_ALERT, "<A> " fmt, ##__VA_ARGS__)
#define logcrit(fmt, ...) logit(LOG_CRIT, "<C> " fmt, ##__VA_ARGS__)
#define logerr(fmt, ...) logit(LOG_ERR, "<e> " fmt, ##__VA_ARGS__)
#define logwarn(fmt, ...) logit(LOG_WARNING, "<w> " fmt, ##__VA_ARGS__)
#define lognotice(fmt, ...) logit(LOG_NOTICE, "<n> " fmt, ##__VA_ARGS__)
#define loginfo(fmt, ...) logit(LOG_INFO, "<i> " fmt, ##__VA_ARGS__)
#define logdebug(fmt, ...) logit(LOG_DEBUG, fmt, ##__VA_ARGS__)
/*
* @param ident an input value (by pointer)
*
*/
extern void initlog(const char* ident);
extern void initlog(const char *ident);
/*
* deinitialize the logging routine
*

View File

@@ -14,18 +14,18 @@
#include <ocmw_helper.h>
#include <Framework.h>
#define HIT_FILE_BUFF_SIZE 50
#define OCCLI_STRING_SIZE 128
#define RES_STR_BUFF_SIZE 10000
#define OCMP_MAX_SIZE 10
#define OCCLI_CHAR_ARRAY_SIZE 30
#define OCMW_MAX_SUBSYSTEM 11
#define HIT_FILE_BUFF_SIZE 50
#define OCCLI_STRING_SIZE 128
#define RES_STR_BUFF_SIZE 100000
#define OCMP_MAX_SIZE 10
#define OCCLI_CHAR_ARRAY_SIZE 30
#define OCMW_MAX_SUBSYSTEM 11
/* This timeout must be more than OCMW timeout */
#define OCCLI_TIMEOUT_PERIOD 12
#define FAILED -1
#define SUCCESS 0
#define OCCLI_SNPRINTF_MAX_LEN 200
#define OCCLI_HELP_MAX_SIZE 400
#define OCCLI_TIMEOUT_PERIOD 12
#define FAILED -1
#define SUCCESS 0
#define OCCLI_SNPRINTF_MAX_LEN 200
#define OCCLI_HELP_MAX_SIZE 400
typedef struct {
char option;
@@ -34,11 +34,11 @@ typedef struct {
} OCCLI_ARRAY_PARAM;
typedef struct {
char subsystem[OCCLI_CHAR_ARRAY_SIZE];
char component[OCCLI_CHAR_ARRAY_SIZE];
char subcomponent[OCCLI_CHAR_ARRAY_SIZE];
char msgtype[OCCLI_CHAR_ARRAY_SIZE];
char parameter[OCCLI_CHAR_ARRAY_SIZE];
char subsystem[OCCLI_CHAR_ARRAY_SIZE];
char component[OCCLI_CHAR_ARRAY_SIZE];
char subcomponent[OCCLI_CHAR_ARRAY_SIZE];
char msgtype[OCCLI_CHAR_ARRAY_SIZE];
char parameter[OCCLI_CHAR_ARRAY_SIZE];
} strMsgFrame;
typedef struct {
@@ -56,7 +56,6 @@ typedef struct {
char *parameter;
} OCCLI_STRING_MSG;
typedef struct {
int32_t totalNum;
struct name {
@@ -65,7 +64,7 @@ typedef struct {
} Info[OCCLI_CHAR_ARRAY_SIZE];
} subSystemInfo;
//Help Menu structure
// Help Menu structure
typedef struct {
char subSystem[OCMW_MAX_SUBSYSTEM_SIZE];
char component[OCMW_HELP_FRAME_SIZE];
@@ -83,6 +82,7 @@ typedef struct {
} commandFrame;
/*
* Initialize the ocmw communication
*/
extern int32_t occli_init_comm(void);
@@ -119,8 +119,7 @@ extern int32_t occli_recv_alertmsg_from_ocmw(char *resp, int32_t resplen);
*
* @return true if function succeeds, false otherwise
*/
extern int32_t ocmw_parse_msgframe(const Component *root,
strMsgFrame *msgFrame,
extern int32_t ocmw_parse_msgframe(const Component *root, strMsgFrame *msgFrame,
uint8_t actiontype,
ocmwSchemaSendBuf *ecSendBuf);
/*
@@ -186,9 +185,19 @@ extern void ocmw_free_global_pointer(void **ptr);
*
* @return true if function succeeds, false otherwise
*/
extern int8_t occli_printHelpMenu(const Component *root,char *cmd);
extern int8_t occli_printHelpMenu(const Component *root, char *cmd);
/*Display CLI window*/
extern void occli_print_opencelluar();
/*
* @param root an output value (by pointer)
* @param systemInfo an output value (by pointer)
*
* @return true if function succeeds, false otherwise
*/
extern void ocmw_handle_alert_msg(const Component *compBase,
OCMPMessageFrame *ecReceivedMsg,
int8_t *alertRecord);
#endif /* _OCCLI_COMM_H_ */

View File

@@ -17,10 +17,11 @@ sem_t semCliReturn;
sem_t semCommandPost;
/* This timeout must be less than CLI timeout */
#define OCMW_SEM_WAIT_TIME 10
#define OCMW_BUSY_WAIT_INDEX 0
#define OCMW_TIMED_WAIT_INDEX 1
#define PARAM_STR_MAX_BUFF_SIZE 100
#define OCMW_SEM_WAIT_TIME 10
#define OCMW_BUSY_WAIT_INDEX 0
#define OCMW_TIMED_WAIT_INDEX 1
#define PARAM_STR_MAX_BUFF_SIZE 100
#define ALERT_MAX_BUFF_SIZE 400
extern int32_t ocmw_init();
/*
@@ -32,9 +33,10 @@ extern int32_t ocmw_init();
*
* @return true if function succeeds, false otherwise
*/
extern int32_t ocmw_msg_packetize_and_send(char * argv[], uint8_t actionType,
uint8_t msgType, const int8_t * paramStr, uint8_t interface,
void* paramVal);
extern int32_t ocmw_msg_packetize_and_send(char *argv[], uint8_t actionType,
uint8_t msgType,
const int8_t *paramStr,
uint8_t interface, void *paramVal);
/*
* Message parser module
*
@@ -44,13 +46,13 @@ extern void ocmw_ec_msgparser(void);
* Thread to parse the data coming from EC to AP through uart
* @param pthreadData an input value (by pointer)
*/
extern void * ocmw_thread_uartmsgparser(void *pthreadData);
extern void *ocmw_thread_uartmsgparser(void *pthreadData);
/*
* Thread to parse the data coming from EC to AP through ethernet
* @param pthreadData an input value (by pointer)
*/
extern void * ocmw_thread_ethmsgparser(void *pthreadData);
extern void *ocmw_thread_ethmsgparser(void *pthreadData);
/*
* @param ecMsgFrame an input structure (by value)
* @param interface an input enum value (by value)

View File

@@ -22,8 +22,8 @@
#include <unistd.h>
#include <stdint.h>
#define OCMW_EC_DEV 1
#define OCMW_EC_STUB_DEV 2
#define OCMW_EC_DEV 1
#define OCMW_EC_STUB_DEV 2
/*
* Initialize the ocmw ethernet communication
@@ -43,12 +43,14 @@ extern int32_t ocmw_deinit_eth_comm(int32_t sentDev);
*
* @return true if function succeeds, false otherwise
*/
extern int32_t ocmw_send_eth_msgto_ec(const int8_t *cmd, int32_t cmdlen,int32_t sentDev);
extern int32_t ocmw_send_eth_msgto_ec(const int8_t *cmd, int32_t cmdlen,
int32_t sentDev);
/*
* @param resp an input value (by pointer)
* @param resplen an input value (by value)
*
* @return true if function succeeds, false otherwise
*/
extern int32_t ocmw_recv_eth_msgfrom_ec(int8_t *resp, int32_t resplen, int32_t sentDev);
extern int32_t ocmw_recv_eth_msgfrom_ec(int8_t *resp, int32_t resplen,
int32_t sentDev);
#endif /* _OCCLI_IPC_COMM_H_ */

View File

@@ -28,41 +28,44 @@
#include <ocmp_frame.h>
#include <ocmw_uart_comm.h>
#define Buf_PARAM_STRUCT_MAX_SIZE 16
#define MAX_PARM_COUNT (OCMP_MSG_SIZE - (sizeof(OCMPMessage)\
- sizeof(void *) + sizeof (OCMPHeader)))
#define Buf_PARAM_STRUCT_MAX_SIZE 16
#define MAX_PARM_COUNT \
(OCMP_MSG_SIZE - \
(sizeof(OCMPMessage) - sizeof(void *) + sizeof(OCMPHeader)))
#define DEBUG_SUBSYSTEM_NBR 11
#define DEBUG_I2C 3
#define DEBUG_MDIO 8
#define DEBUG_SUBSYSTEM_NBR 11
#define DEBUG_I2C 3
#define DEBUG_MDIO 8
#define PARAM_STR_BUFF_SIZE 100
#define PARAM_TYPE_BUFF_SIZE 32
#define OCMW_MAX_SUBSYSTEM_SIZE 16
#define OCMW_MAX_ACTION_SIZE 16
#define OCMW_MAX_MSGTYPE_SIZE 16
#define OCMW_COMMAND_BUFF_SIZE 20
#define OCMW_POST_DESC_SIZE 24
#define OCMW_HELP_FRAME_SIZE 40
#define OCMW_POST_DEVICE_SIZE 40
#define EEPROM_STATUS_MAX_SIZE 21
#define EEPROM_SDR_STATUS_SIZE 19
#define EEPROM_CONFIG_MAX_SIZE 14
#define EEPROM_CONFIG_SIZE 18
#define OCMW_MAX_POST_CODE_SIZE 100
#define TEMP_STR_BUFF_SIZE 100
#define PARAM_STR_BUFF_SIZE 100
#define PARAM_TYPE_BUFF_SIZE 32
#define OCMW_ALERT_ACTION_SIZE 12
#define OCMW_MAX_SUBSYSTEM_SIZE 16
#define OCMW_MAX_ACTION_SIZE 16
#define OCMW_MAX_MSGTYPE_SIZE 16
#define OCMW_COMMAND_BUFF_SIZE 20
#define OCMW_POST_DESC_SIZE 24
#define OCMW_ALERT_DATE_SIZE 24
#define OCMW_HELP_FRAME_SIZE 40
#define OCMW_POST_DEVICE_SIZE 40
#define OCMW_ALERT_STRING_SIZE 64
#define EEPROM_STATUS_MAX_SIZE 21
#define EEPROM_SDR_STATUS_SIZE 19
#define EEPROM_CONFIG_MAX_SIZE 14
#define EEPROM_CONFIG_SIZE 18
#define OCMW_MAX_POST_CODE_SIZE 100
#define TEMP_STR_BUFF_SIZE 100
typedef enum {
VOID = 0,
CHAR = 1,
UCHAR = 1,
SHORT = 2,
USHORT = 2,
INT = 4,
UINT = 4,
FLOAT = 4
VOID = 0,
CHAR = 1,
UCHAR = 1,
SHORT = 2,
USHORT = 2,
INT = 4,
UINT = 4,
FLOAT = 4
} DATA_TYPE;
typedef enum {
@@ -98,25 +101,44 @@ typedef struct {
char commandType[OCMW_COMMAND_BUFF_SIZE];
} ocmwSchemaSendBuf;
typedef struct __attribute__((packed, aligned(1))){
uint8_t devsn; /* device serial Number */
typedef struct __attribute__((packed, aligned(1))) {
uint8_t devsn; /* device serial Number */
uint8_t subsystem;
char subsysName[OCMW_MAX_SUBSYSTEM_SIZE]; /* Subsystem Name */
char deviceName[OCMW_POST_DEVICE_SIZE]; /* Device Name */
uint8_t status; /* device status */
char subsysName[OCMW_MAX_SUBSYSTEM_SIZE]; /* Subsystem Name */
char deviceName[OCMW_POST_DEVICE_SIZE]; /* Device Name */
uint8_t status; /* device status */
} ocwarePostResultData;
typedef struct {
unsigned int count; /* Device Status count */
ocwarePostResultData results[OCMW_MAX_POST_CODE_SIZE]; /* Post result structure */
unsigned int count; /* Device Status count */
ocwarePostResultData
results[OCMW_MAX_POST_CODE_SIZE]; /* Post result structure */
} ocwarePostResults;
typedef struct {
uint8_t msgtype; /* Post Message tyep */
uint8_t replycode; /* Reply type */
char desc[OCMW_POST_DESC_SIZE]; /* Device description */
uint8_t msgtype; /* Post Message tyep */
uint8_t replycode; /* Reply type */
char desc[OCMW_POST_DESC_SIZE]; /* Device description */
} ocwarePostReplyCode;
typedef struct alertevent {
char string[OCMW_ALERT_STRING_SIZE]; /* alert string */
char action[OCMW_ALERT_ACTION_SIZE]; /* ACTIVE / CLEAR */
char value[OCMW_ALERT_STRING_SIZE];
} alertevent;
typedef struct allAlertEvent {
char string[OCMW_ALERT_STRING_SIZE]; /* alert string */
char action[OCMW_ALERT_ACTION_SIZE]; /* ACTIVE / CLEAR */
char datetime[OCMW_ALERT_DATE_SIZE]; /* YYYY-MM-DD hh:mm:ss */
char value[OCMW_ALERT_STRING_SIZE];
char actualValue[OCMW_ALERT_STRING_SIZE];
} allAlertEvent;
typedef struct alertlist {
uint16_t nalerts; /* Number of alerts */
struct allAlertEvent *list; /* Alert list */
} alertlist;
/*
* @param sem an input value (by pointer)
*
@@ -129,7 +151,8 @@ extern int32_t ocmw_sem_wait_nointr(sem_t *sem);
*
* @return true if function succeeds, false otherwise
*/
extern int32_t ocmw_sem_timedwait_nointr(sem_t *sem, const struct timespec *timeout);
extern int32_t ocmw_sem_timedwait_nointr(sem_t *sem,
const struct timespec *timeout);
/*
* @param paramindex an input value (by value)
* @param paramSizebuf an input value (by pointer)
@@ -138,14 +161,14 @@ extern int32_t ocmw_sem_timedwait_nointr(sem_t *sem, const struct timespec *time
*
*/
extern void ocmw_dataparsing_from_db(int32_t paramIndex, int32_t *paramSizebuf,
int32_t *dataSize, int32_t *pos);
int32_t *dataSize, int32_t *pos);
/*
* @param input an input buffer (by pointer)
* @param bufParamStruct an output buffer (by pointer)
*
*/
extern void ocmw_dataparsing_from_ec(ocmwSendRecvBuf *input,
bufParam * bufParamStruct);
bufParam *bufParamStruct);
/*
* @param uartInputBuf an input buffer (by pointer)
*
@@ -157,7 +180,7 @@ extern int32_t ocmw_fill_inputstruct(ocmwSendRecvBuf *uartInputBuf);
*
* @return true if function succeeds, false otherwise
*/
extern int8_t ocmw_parse_eepromdata_from_ec (ocmwSendRecvBuf ecInputData);
extern int8_t ocmw_parse_eepromdata_from_ec(ocmwSendRecvBuf ecInputData);
/*
* @param ecInputData an input data (by value)
*
@@ -170,4 +193,12 @@ extern int32_t ocmw_parse_obc_from_ec(ocmwSendRecvBuf ecInputData);
* @return true if function succeeds, false otherwise
*/
extern int32_t ocmw_parse_testingmodule_from_ec(ocmwSendRecvBuf ecInputData);
/*
* @param msgaction an input value (by value)
* @param msgtype an input value (by value)
* @param paramstr an input string (by pointer)
* @param paramvalue an input value (by pointer)
*
*/
extern int32_t ocmw_handle_show_alerts(char *response);
#endif /* _OCMW_HELPER_H_ */

4
firmware/host/include/ocmw_msgproc.h Executable file → Normal file
View File

@@ -11,7 +11,7 @@
#include "ocmp_frame.h"
extern int ocmw_msgproc_send_msg(char * argv[], uint8_t action, int8_t msgtype,
const int8_t* paramstr, void* paramvalue);
extern int ocmw_msgproc_send_msg(char *argv[], uint8_t action, int8_t msgtype,
const int8_t *paramstr, void *paramvalue);
#endif /* _OCMW_MSGPROC_H_ */

View File

@@ -11,14 +11,15 @@
#include <ocmw_helper.h>
#define PARAMSTR_NUMBER_LEN 12
#define TESTMOD_MAX_LEN 16
#define RES_STR_BUFF_SIZE 10000
#define TEMP_STR_BUFF_SIZE 100
#define ALERT_STR_BUFF_SIZE 128
#define CMD_STR_BUFF_SIZE 100
#define OCMW_MAX_IMEI_SIZE 15
#define OCMW_MAX_MSG_SIZE 20
#define PARAMSTR_NUMBER_LEN 12
#define TESTMOD_MAX_LEN 16
#define RES_STR_BUFF_SIZE 100000
#define TEMP_STR_BUFF_SIZE 100
#define FINAL_STR_BUFF_SIZE 100
#define ALERT_STR_BUFF_SIZE 200
#define CMD_STR_BUFF_SIZE 100
#define OCMW_MAX_IMEI_SIZE 15
#define OCMW_MAX_MSG_SIZE 20
typedef struct {
int8_t pin;
@@ -30,7 +31,7 @@ typedef struct {
uint16_t regValue;
} debugMDIOData;
typedef struct __attribute__((packed, aligned(1))){
typedef struct __attribute__((packed, aligned(1))) {
uint8_t slaveAddress;
uint8_t numOfBytes;
uint8_t regAddress;
@@ -55,6 +56,7 @@ typedef enum {
DLOOPBK_STR,
EPKTGEN_STR,
DPKTGEN_STR,
ALERTLOG_STR,
MAX_STR
} ocmw_token_t;
@@ -85,14 +87,15 @@ extern int32_t ocmw_deinit_occli_comm(void);
*
* @return true if function succeeds, false otherwise
*/
extern int32_t ocmw_recv_clicmd_from_occli(char* cmdstr, int32_t cmdlen);
extern int32_t ocmw_recv_clicmd_from_occli(char *cmdstr, int32_t cmdlen);
/*
* @param resp an input value (by pointer)
* @param resplen an input value (by value)
*
* @return true if function succeeds, false otherwise
*/
extern int32_t ocmw_send_clicmd_resp_to_occli(const char* resp, int32_t resplen);
extern int32_t ocmw_send_clicmd_resp_to_occli(const char *resp,
int32_t resplen);
/*
* @param cmdstr an input value (by pointer)
* @param response an output value (by pointer)
@@ -118,7 +121,7 @@ extern int32_t ocmw_deinit_occli_alert_comm(void);
*
* @return true if function succeeds, false otherwise
*/
extern int32_t ocmw_send_alert_to_occli(const char* buf, int32_t buflen);
extern int32_t ocmw_send_alert_to_occli(const char *buf, int32_t buflen);
extern char ocmw_retrieve_post_results_count(ocwarePostResults *psData);

View File

@@ -1,45 +1,40 @@
/* OC Includes */
#include <occli_common.h>
#include <ocmw_core.h>
#ifndef _OCMW_SCHEMA_H_
#define _OCMW_SCHEMA_H_
# define _OCMW_SCHEMA_H_
#define OCMW_VALUE_TYPE_UINT8 1
#define OCMW_VALUE_TYPE_INT8 2
#define OCMW_VALUE_TYPE_UINT16 3
#define OCMW_VALUE_TYPE_INT16 6
#define OCMW_VALUE_TYPE_UINT32 11
#define OCMW_VALUE_TYPE_ENUM 9
#define OCMW_VALUE_TYPE_MFG 10
#define OCMW_VALUE_TYPE_MODEL 4
#define OCMW_VALUE_TYPE_GETMODEL 5
#define OCMW_VALUE_TYPE_STRUCT 7
#define OCMW_VALUE_TYPE_NWOP_STRUCT 12
#define IRIDIUM_LASTERR_ERROR_CODE_OFFSET 2
#define TWO_G_SIM_NET_OPTR_STATUS_OFFSET 2
#define BUF_SIZE 50
#define ENUM_BUF_SIZE 30
#define OCMW_VALUE_TYPE_COMPLEX 3
# define OCMW_VALUE_TYPE_UINT8 1
# define OCMW_VALUE_TYPE_INT8 2
# define OCMW_VALUE_TYPE_UINT16 3
# define OCMW_VALUE_TYPE_INT16 6
# define OCMW_VALUE_TYPE_UINT32 11
# define OCMW_VALUE_TYPE_ENUM 9
# define OCMW_VALUE_TYPE_MFG 10
# define OCMW_VALUE_TYPE_MODEL 4
# define OCMW_VALUE_TYPE_GETMODEL 5
# define OCMW_VALUE_TYPE_STRUCT 7
# define OCMW_VALUE_TYPE_NWOP_STRUCT 12
# define IRIDIUM_LASTERR_ERROR_CODE_OFFSET 2
# define TWO_G_SIM_NET_OPTR_STATUS_OFFSET 2
# define BUF_SIZE 50
# define ENUM_BUF_SIZE 30
# define OCMW_VALUE_TYPE_COMPLEX 3
static const char *DATA_TYPE_MAP[] = {
[TYPE_NULL] = "NULL",
[TYPE_INT8] = "int8",
[TYPE_UINT8] = "uint8",
[TYPE_INT16] = "int16",
[TYPE_UINT16] = "uint16",
[TYPE_INT32] = "int32",
[TYPE_UINT32] = "uint32",
[TYPE_INT64] = "int64",
[TYPE_UINT64] = "uint64",
[TYPE_STR] = "string",
[TYPE_BOOL] = "bool",
[TYPE_ENUM] = "enum",
[TYPE_NULL] = "NULL", [TYPE_INT8] = "int8",
[TYPE_UINT8] = "uint8", [TYPE_INT16] = "int16",
[TYPE_UINT16] = "uint16", [TYPE_INT32] = "int32",
[TYPE_UINT32] = "uint32", [TYPE_INT64] = "int64",
[TYPE_UINT64] = "uint64", [TYPE_STR] = "string",
[TYPE_BOOL] = "bool", [TYPE_ENUM] = "enum",
};
typedef enum ErrorSource {
ERR_RC_INTERNAL = 0,
ERR_SRC_CMS = 1,
ERR_SRC_CME = 2
ERR_RC_INTERNAL = 0,
ERR_SRC_CMS = 1,
ERR_SRC_CME = 2
} Source;
typedef enum OperatorStat {

View File

@@ -9,34 +9,33 @@
#ifndef _OCMW_SOCK_COMM_H_
#define _OCMW_SOCK_COMM_H_
#define OCMW_SOCK_SERVER_IP ("127.0.0.1")
#define OCMW_SOCK_SERVER_PORT (5000)
#define OCMW_SOCK_SERVER_ALERT_PORT (6000)
#define OCMW_SOCK_SERVER_IP ("127.0.0.1")
#define OCMW_SOCK_SERVER_PORT (5000)
#define OCMW_SOCK_SERVER_ALERT_PORT (6000)
#define OCMW_SOCK_SERVER_CONN_COUNT (1)
#define OCMW_SOCK_SERVER_ALERT_CONN_COUNT (2)
#define OCMW_SOCK_SERVER_CONN_COUNT (1)
#define OCMW_SOCK_SERVER_ALERT_CONN_COUNT (2)
#define OCMW_SOCK_DOMAIN (AF_INET)
#define OCMW_SOCK_TYPE (SOCK_DGRAM)
#define OCMW_SOCK_PROTOCOL (IPPROTO_UDP)
#define OCMW_SOCK_DOMAIN (AF_INET)
#define OCMW_SOCK_TYPE (SOCK_DGRAM)
#define OCMW_SOCK_PROTOCOL (IPPROTO_UDP)
#define OCMW_SOCK_ALERT_SERVER_IP ("127.0.0.1")
#define OCMW_SOCK_ALERT_SERVER_PORT (6000)
#define OCMW_SOCK_ALERT_DOMAIN (AF_INET)
#define OCMW_SOCK_ALERT_TYPE (SOCK_DGRAM)
#define OCMW_SOCK_ALERT_PROTOCOL (IPPROTO_UDP)
#define OCMW_SOCK_ALERT_SERVER_IP ("127.0.0.1")
#define OCMW_SOCK_ALERT_SERVER_PORT (6000)
#define OCMW_SOCK_ALERT_DOMAIN (AF_INET)
#define OCMW_SOCK_ALERT_TYPE (SOCK_DGRAM)
#define OCMW_SOCK_ALERT_PROTOCOL (IPPROTO_UDP)
#define OCMW_ETH_SOCK_SERVER_IP ("192.168.1.2")
#define OCMW_ETH_SOCK_SERVER_PORT (1000)
#define OCMW_ETH_SOCK_DOMAIN (AF_INET)
#define OCMW_ETH_SOCK_TYPE (SOCK_STREAM)
#define OCMW_ETH_SOCK_PROTOCOL (IPPROTO_TCP)
#define OCMW_SOCKET_ERROR_SIZE 256
#define OCMW_ETH_SOCK_SERVER_IP ("192.168.1.2")
#define OCMW_ETH_SOCK_SERVER_PORT (1000)
#define OCMW_ETH_SOCK_DOMAIN (AF_INET)
#define OCMW_ETH_SOCK_TYPE (SOCK_STREAM)
#define OCMW_ETH_SOCK_PROTOCOL (IPPROTO_TCP)
#define OCMW_SOCKET_ERROR_SIZE 256
#define OCMW_SOCK_STUB_SERVER_IP ("127.0.0.1")
#define OCMW_SOCK_STUB_SERVER_PORT (2000)
#define OCMW_SOCK_STUB_DOMAIN (AF_INET)
#define OCMW_SOCK_STUB_TYPE (SOCK_DGRAM)
#define OCMW_SOCK_STUB_PROTOCOL (IPPROTO_UDP)
#define OCMW_SOCK_STUB_SERVER_IP ("127.0.0.1")
#define OCMW_SOCK_STUB_SERVER_PORT (2000)
#define OCMW_SOCK_STUB_DOMAIN (AF_INET)
#define OCMW_SOCK_STUB_TYPE (SOCK_DGRAM)
#define OCMW_SOCK_STUB_PROTOCOL (IPPROTO_UDP)
#endif /* _OCMW_SOCK_COMM_H_ */

View File

@@ -9,12 +9,12 @@
#ifndef _OCMW_UART_COMM_H_
#define _OCMW_UART_COMM_H_
#ifdef INTERFACE_USB
#define ECTTY "sudo find /dev/ -iname \"ttyACM*\" | tr -cd [:digit:]"
#ifdef INTERFACE_USB
# define ECTTY "sudo find /dev/ -iname \"ttyACM*\" | tr -cd [:digit:]"
#else
#define ECTTY "/dev/ttyS4"
# define ECTTY "/dev/ttyS4"
#endif
#define OCMP_MSG_SIZE (64)
#define OCMP_MSG_SIZE (64)
/*
* @param msgstr an input value (by pointer)
@@ -22,14 +22,15 @@
*
* @return the function handler
*/
typedef void
(*handle_msg_from_ec_t)(const unsigned char* msgstr, int32_t msgsize);
typedef void (*handle_msg_from_ec_t)(const unsigned char *msgstr,
int32_t msgsize);
/*
* @param msgstr an input value (by pointer)
* @param msgsize an input value (by value)
*
*/
extern void ocmw_ec_uart_msg_hndlr(const unsigned char* msgstr, int32_t msgsize);
extern void ocmw_ec_uart_msg_hndlr(const unsigned char *msgstr,
int32_t msgsize);
/*
* Initialize the ocmw ec communication
*
@@ -48,7 +49,7 @@ extern int32_t ocmw_deinit_ec_comm(void);
*
* @return true if function succeeds, false otherwise
*/
extern int32_t ocmw_send_uart_msg_to_ec(const uint8_t* msgstr, int32_t size);
extern int32_t ocmw_send_uart_msg_to_ec(const uint8_t *msgstr, int32_t size);
/*
* @param pathName an input value (by pointer)
*

12
firmware/host/include/ocware_stub_eth_comm.h Executable file → Normal file
View File

@@ -6,11 +6,11 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#define OCMW_STUB_ETH_SOCK_DOMAIN (AF_INET)
#define OCMW_STUB_ETH_SOCK_TYPE (SOCK_DGRAM)
#define OCMW_STUB_ETH_SOCK_PROTOCOL (IPPROTO_UDP)
#define OCMW_STUB_ETH_SOCK_SERVER_PORT (2000)
#define OCMW_STUB_ETH_SOCK_SERVER_IP ("127.0.0.1")
#define OCWARE_STUB_ERR_STR_LEN (80)
#define OCMW_STUB_ETH_SOCK_DOMAIN (AF_INET)
#define OCMW_STUB_ETH_SOCK_TYPE (SOCK_DGRAM)
#define OCMW_STUB_ETH_SOCK_PROTOCOL (IPPROTO_UDP)
#define OCMW_STUB_ETH_SOCK_SERVER_PORT (2000)
#define OCMW_STUB_ETH_SOCK_SERVER_IP ("127.0.0.1")
#define OCWARE_STUB_ERR_STR_LEN (80)
#endif /* _STUB_ETH_COMM_H_ */

148
firmware/host/include/ocware_stub_main_module.h Executable file → Normal file
View File

@@ -18,49 +18,49 @@
#include <math.h>
#include <ocmp_frame.h>
#define OC_EC_MSG_SIZE (64)
#define MAX_PAYLOAD_COUNT (OC_EC_MSG_SIZE - sizeof (OCMPHeader))
#define OC_EC_MSG_SIZE (64)
#define MAX_PAYLOAD_COUNT (OC_EC_MSG_SIZE - sizeof(OCMPHeader))
/* Max parameters to be stored in database */
#define MAX_NUMBER_PARAM 400
#define MAX_POST_DEVICE 400
#define MAX_I2C_COMP_NBR 1
#define MAX_GPIO_COMP_NBR 1
#define MAX_MDIO_COMP_NBR 1
#define MAX_NUMBER_PARAM 400
#define MAX_POST_DEVICE 400
#define MAX_I2C_COMP_NBR 1
#define MAX_GPIO_COMP_NBR 1
#define MAX_MDIO_COMP_NBR 1
/* Default values in the database */
#define DEFAULT_INT8 0x11
#define DEFAULT_INT16 0x2222
#define DEFAULT_INT32 0x33333333
#define DEFAULT_INT64 0x4444444444444444
#define DEFAULT_ENUM 0x05
#define DEFAULT_STRING "stub"
#define DEFAULT_INT8 0x11
#define DEFAULT_INT16 0x2222
#define DEFAULT_INT32 0x33333333
#define DEFAULT_INT64 0x4444444444444444
#define DEFAULT_ENUM 0x05
#define DEFAULT_STRING "stub"
/* default values in the debug subsystem */
#define I2C_SLAVE_ADDRESS 1
#define I2C_NUM_BYTES 1
#define I2C_REG_ADDRESS 1
#define I2C_REG_VALUE 1
#define GPIO_PIN_NBR 1
#define GPIO_VALUE 1
#define I2C_SLAVE_ADDRESS 1
#define I2C_NUM_BYTES 1
#define I2C_REG_ADDRESS 1
#define I2C_REG_VALUE 1
#define GPIO_PIN_NBR 1
#define GPIO_VALUE 1
/* size of strings and enum dataypes in schema */
#define SIZE_OF_TYPE_REGISTRATION 1
#define SIZE_OF_NWOP_STRUCT 3
#define SIZE_OF_LAST_ERROR 3
#define SIZE_OF_TYPE_MFG 10
#define SIZE_OF_TYPE_GETMODEL 5
#define SIZE_OF_TYPE_MODEL 4
#define SIZE_OF_NWOP_STRUCT 3
#define SIZE_OF_LAST_ERROR 3
#define SIZE_OF_TYPE_OCSERIAL_INFO 18
#define SIZE_OF_TYPE_GBCBOARD_INFO 18
#define SIZE_OF_TYPE_MACADDR 13
#define SIZE_OF_TYPE_REGISTRATION 1
#define SIZE_OF_NWOP_STRUCT 3
#define SIZE_OF_LAST_ERROR 3
#define SIZE_OF_TYPE_MFG 10
#define SIZE_OF_TYPE_GETMODEL 5
#define SIZE_OF_TYPE_MODEL 4
#define SIZE_OF_NWOP_STRUCT 3
#define SIZE_OF_LAST_ERROR 3
#define SIZE_OF_TYPE_OCSERIAL_INFO 18
#define SIZE_OF_TYPE_GBCBOARD_INFO 18
#define SIZE_OF_TYPE_MACADDR 13
/* Masking related defines */
#define MASK_MSB 0xFF00
#define MASK_LSB 0xFF
#define SHIFT_NIBBLE 8
#define MASK_MSB 0xFF00
#define MASK_LSB 0xFF
#define SHIFT_NIBBLE 8
typedef struct {
uint8_t subsystemId;
@@ -73,7 +73,7 @@ typedef struct {
void *data;
} OCWareStubDatabase;
typedef struct{
typedef struct {
uint8_t SubsystemId;
uint8_t DeviceNumber;
ePostCode Status;
@@ -111,11 +111,17 @@ typedef struct {
uint8_t value;
} OCWareDebugGPIOinfo;
typedef enum ocware_ret{
STUB_FAILED = -1,
STUB_SUCCESS = 0
} ocware_stub_ret;
typedef enum ocware_ret { STUB_FAILED = -1, STUB_SUCCESS = 0 } ocware_stub_ret;
typedef struct {
uint8_t subsystemId;
uint8_t componentId;
uint8_t msgtype;
uint16_t paramId;
uint8_t paramSize;
uint8_t datatype;
void *data;
} OCWareStubAlertData;
extern int8_t debugGetCommand;
extern int8_t debugSetCommand;
@@ -142,7 +148,8 @@ extern ocware_stub_ret ocware_stub_parse_post_get_message(char *buffer);
* @return STUB_SUCCESS - for success
* STUB_FAILED - for failure
******************************************************************************/
extern ocware_stub_ret ocware_stub_parse_command_message(char *buffer);
extern ocware_stub_ret ocware_stub_parse_command_message(char *buffer,
uint8_t *alertFlag);
/******************************************************************************
* Function Name : ocware_stub_get_set_params
@@ -173,7 +180,8 @@ extern ocware_stub_ret ocware_stub_init_database(void);
* @return STUB_SUCCESS - for success
* STUB_FAILED - for failure
******************************************************************************/
extern ocware_stub_ret ocware_stub_send_msgframe_middleware(char **buffer, int32_t bufferlen);
extern ocware_stub_ret ocware_stub_send_msgframe_middleware(char **buffer,
int32_t bufferlen);
/******************************************************************************
* Function Name : ocware_stub_init_ethernet_comm
* Description : initialise the socket IPC
@@ -201,7 +209,8 @@ extern ocware_stub_ret ocware_stub_deinit_ethernet_comm();
* @return STUB_SUCCESS - for success
* STUB_FAILED - for failure
******************************************************************************/
extern ocware_stub_ret ocware_stub_recv_msgfrom_middleware(char **buffer, int32_t bufferlen);
extern ocware_stub_ret ocware_stub_recv_msgfrom_middleware(char **buffer,
int32_t bufferlen);
/******************************************************************************
* Function Name : ocware_stub_get_database
* Description : Function to retrieve data from the DB
@@ -234,9 +243,9 @@ extern ocware_stub_ret ocware_stub_set_database(OCMPMessage *msgFrameData);
* @return STUB_SUCCESS - for success
* STUB_FAILED - for failure
******************************************************************************/
extern ocware_stub_ret ocware_stub_get_post_result_paramvalue_from_table(
OCMPMessage *msgFrameData,
int8_t *payload);
extern ocware_stub_ret
ocware_stub_get_post_result_paramvalue_from_table(OCMPMessage *msgFrameData,
int8_t *payload);
/******************************************************************************
* Function Name : ocware_stub_parse_debug_actiontype
* Description : Convert debug actiontype into the SET/GET
@@ -247,7 +256,8 @@ extern ocware_stub_ret ocware_stub_get_post_result_paramvalue_from_table(
* @return STUB_SUCCESS - for success
* STUB_FAILED - for failure
******************************************************************************/
extern ocware_stub_ret ocware_stub_parse_debug_actiontype(OCMPMessage *msgFrameData);
extern ocware_stub_ret
ocware_stub_parse_debug_actiontype(OCMPMessage *msgFrameData);
/******************************************************************************
* Function Name : ocware_stub_get_post_database
* Description : extract device number and status from the post database
@@ -262,5 +272,53 @@ extern ocware_stub_ret ocware_stub_parse_debug_actiontype(OCMPMessage *msgFrameD
******************************************************************************/
extern ocware_stub_ret ocware_stub_get_post_database(OCMPMessage *msgFrameData,
char *payload);
/******************************************************************************
* Function Name : ocware_stub_parse_alert_get_message
* Description : Parse alert messages from MW
*
* @param buffer - output pointer to the message from MW
* index - index for record
*
* @return STUB_SUCCESS - for success
* STUB_FAILED - for failure
******************************************************************************/
extern ocware_stub_ret ocware_stub_parse_alert_get_message(char *buffer,
int8_t index);
/******************************************************************************
* Function Name : ocware_stub_get_alert_database
* Description : extract alert data from lookup table
*
* @param msgFrameData - output pointer to the OCMPheader field of the message
* from MW (by reference)
* @param payload - output pointer to the payload field of the message from MW
*
* @return STUB_SUCCESS - for success
* STUB_FAILED - for failure
******************************************************************************/
extern ocware_stub_ret ocware_stub_get_alert_database(OCMPMessage *msgFrameData,
char *payload,
int8_t index);
/******************************************************************************
* Function Name : ocware_stub_parse_command_from_schema
* Description : parse command from schema
*
* @param msgFrameData - pointer to the OCMPheader field of the message
* from MW (by reference)
*
* @return tempAlertFlag
******************************************************************************/
extern uint8_t ocware_stub_parse_command_from_schema(OCMPMessage *msgFrameData);
/******************************************************************************
* Function Name : ocware_stub_frame_alert_msgframe
* Description : extract alert data from based on subsystem
*
* @param msgFrameData - output pointer to the OCMPheader field of the message
* from MW (by reference)
* @param payload - output pointer to the payload field of the message from MW
*
* @return STUB_SUCCESS - for success
* STUB_FAILED - for failure
******************************************************************************/
extern ocware_stub_ret ocware_stub_frame_alert_msgframe(char *buffer);
#endif /* __OCMW_STUB_H__ */

View File

@@ -25,6 +25,6 @@ extern int32_t ocwdg_init(void);
* @param pthreadData an input value (by pointer)
*
*/
extern void * ocwdg_thread_comm_with_ec(void *pthreadData);
extern void *ocwdg_thread_comm_with_ec(void *pthreadData);
#endif /* _OCWGD_DAEMON_H_ */

View File

@@ -15,9 +15,9 @@
#include <string.h>
#include <stdlib.h>
#define POST_MAIN_PAYLOAD_SIZE 3
#define POST_MAIN_PAYLOAD_SUBSYSTEM_OFFSET 0
#define POST_MAIN_PAYLOAD_DEVSN_OFFSET 1
#define POST_MAIN_PAYLOAD_STATUS_OFFSET 2
#define POST_MAIN_PAYLOAD_SIZE 3
#define POST_MAIN_PAYLOAD_SUBSYSTEM_OFFSET 0
#define POST_MAIN_PAYLOAD_DEVSN_OFFSET 1
#define POST_MAIN_PAYLOAD_STATUS_OFFSET 2
#endif /* _POST_H_ */

View File

@@ -14,6 +14,6 @@
* @param buflen an input value (by value)
*
*/
extern void hexdisp(const unsigned char* buf, int buflen);
extern void hexdisp(const unsigned char *buf, int buflen);
#endif /* _UTIL_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]
<e> Error: 'recvfrom' [-1-Resource temporarily unavailable]

View File

@@ -12,7 +12,7 @@
void occli_print_opencelluar()
{
printf("\nHELP Usage:\n\t\"subsystem --help\""
" OR \"subsystem.component --help\"");
" OR \"subsystem.component --help\"");
printf("\nEXIT:\n\t\"quit\"");
printf("\nDisplay:\n\t\"Press Double TAB\"");
@@ -27,7 +27,8 @@ void occli_print_opencelluar()
* Output(s) : index, helpMenuArray
***************************************************************************/
int8_t occli_fill_data_from_param(const Parameter *param,
helpMenu *helpMenuArray[], int32_t *index, char *helpMsgType)
helpMenu *helpMenuArray[], int32_t *index,
char *helpMsgType)
{
int32_t helpIndex = *index;
@@ -37,17 +38,17 @@ int8_t occli_fill_data_from_param(const Parameter *param,
}
if (param && param->name) {
strncpy(helpMenuArray[helpIndex]->msgType,
helpMsgType,strlen(helpMsgType));
strncpy(helpMenuArray[helpIndex]->msgType, helpMsgType,
strlen(helpMsgType));
if (strcmp(helpMsgType, "config") == 0) {
strncpy(helpMenuArray[helpIndex]->actionType,
"get/set", strlen("get/set"));
strncpy(helpMenuArray[helpIndex]->actionType, "get/set",
strlen("get/set"));
} else {
strncpy(helpMenuArray[helpIndex]->actionType, "get", strlen("get"));
}
do {
strncpy(helpMenuArray[helpIndex]->parameter,
param->name, strlen(param->name));
strncpy(helpMenuArray[helpIndex]->parameter, param->name,
strlen(param->name));
param += 1;
helpIndex++;
} while (param && param->name);
@@ -63,8 +64,8 @@ int8_t occli_fill_data_from_param(const Parameter *param,
* Output(s) : index, helpMenuArray
***************************************************************************/
int8_t occli_fill_data_from_command(const Command *command,
helpMenu *helpMenuArray[], int32_t *index,
char *subSysComp)
helpMenu *helpMenuArray[], int32_t *index,
char *subSysComp)
{
int32_t helpIndex = *index;
@@ -74,44 +75,44 @@ int8_t occli_fill_data_from_command(const Command *command,
}
if (command && command->name) {
strncpy(helpMenuArray[helpIndex]->msgType,
"command", strlen("command"));
strncpy(helpMenuArray[helpIndex]->msgType, "command",
strlen("command"));
while (command && command->name) {
strncpy(helpMenuArray[helpIndex]->actionType,
command->name, strlen(command->name));
strncpy(helpMenuArray[helpIndex]->actionType, command->name,
strlen(command->name));
if (strncmp(subSysComp, "debug", strlen("debug")) == 0) {
if (strstr(subSysComp, "I2C")) {
if (strcmp(command->name, "get") == 0) {
strcpy(helpMenuArray[helpIndex++]->arguments,
"Slave Address(Decimal)");
"Slave Address(Decimal)");
strcpy(helpMenuArray[helpIndex++]->arguments,
"Number of Bytes(1/2)");
"Number of Bytes(1/2)");
strcpy(helpMenuArray[helpIndex++]->arguments,
"Register Address(Decimal)");
"Register Address(Decimal)");
} else {
strcpy(helpMenuArray[helpIndex++]->arguments,
"Slave Address(Decimal)");
"Slave Address(Decimal)");
strcpy(helpMenuArray[helpIndex++]->arguments,
"Number of Bytes(1/2)");
"Number of Bytes(1/2)");
strcpy(helpMenuArray[helpIndex++]->arguments,
"Register Address(Decimal)");
"Register Address(Decimal)");
strcpy(helpMenuArray[helpIndex]->arguments,
"Register Data(Decimal)");
"Register Data(Decimal)");
}
} else {
if (strcmp(command->name, "get") == 0) {
strcpy(helpMenuArray[helpIndex++]->arguments,
"Pin Number");
"Pin Number");
} else {
strcpy(helpMenuArray[helpIndex++]->arguments,
"Pin Number");
"Pin Number");
strcpy(helpMenuArray[helpIndex]->arguments,
"Value(0/1)");
"Value(0/1)");
}
}
} else if ((strncmp(subSysComp, "hci", strlen("hci")) == 0) &&
(strcmp(command->name, "set") == 0)) {
(strcmp(command->name, "set") == 0)) {
strcpy(helpMenuArray[helpIndex++]->arguments, "Off/Red/Green");
}
if (strcmp(command->name, "send") == 0) {
@@ -135,9 +136,8 @@ int8_t occli_fill_data_from_command(const Command *command,
* Input(s) : post, index
* Output(s) : index, helpMenuArray
***************************************************************************/
int8_t occli_fill_data_from_post(const Post *post,
helpMenu *helpMenuArray[], int32_t *index,
char *subSysComp)
int8_t occli_fill_data_from_post(const Post *post, helpMenu *helpMenuArray[],
int32_t *index, char *subSysComp)
{
int32_t helpIndex = *index;
@@ -146,12 +146,11 @@ int8_t occli_fill_data_from_post(const Post *post,
return FAILED;
}
if (post && post->name) {
strncpy(helpMenuArray[helpIndex]->msgType,
"post", strlen("post"));
if (post && post->name) {
strncpy(helpMenuArray[helpIndex]->msgType, "post", strlen("post"));
while (post && post->name) {
strncpy(helpMenuArray[helpIndex]->actionType,
post->name, strlen(post->name));
strncpy(helpMenuArray[helpIndex]->actionType, post->name,
strlen(post->name));
post += 1;
helpIndex++;
}
@@ -168,7 +167,8 @@ int8_t occli_fill_data_from_post(const Post *post,
* Output(s) : helpMenuArray, index
***************************************************************************/
int8_t occli_fill_data_from_driver(const Driver *devDriver,
helpMenu *helpMenuArray[], int32_t *index, char *subSysComp)
helpMenu *helpMenuArray[], int32_t *index,
char *subSysComp)
{
const Parameter *param = NULL;
const Command *command = NULL;
@@ -186,11 +186,10 @@ int8_t occli_fill_data_from_driver(const Driver *devDriver,
ret = occli_fill_data_from_param(param, helpMenuArray, index, "status");
command = devDriver->commands;
ret = occli_fill_data_from_command(command, helpMenuArray,
index, subSysComp);
ret =
occli_fill_data_from_command(command, helpMenuArray, index, subSysComp);
post = devDriver->post;
ret = occli_fill_data_from_post (post, helpMenuArray,
index, subSysComp);
ret = occli_fill_data_from_post(post, helpMenuArray, index, subSysComp);
return ret;
}
@@ -200,8 +199,8 @@ int8_t occli_fill_data_from_driver(const Driver *devDriver,
* Input(s) : helpMenuArray, index, subSystem
* Output(s) : NA
***************************************************************************/
void occli_printHelpMenu_on_console(helpMenu *helpMenuArray[],
int32_t index, char *subSystem)
void occli_printHelpMenu_on_console(helpMenu *helpMenuArray[], int32_t index,
char *subSystem)
{
int32_t printIndex = 0;
@@ -218,24 +217,24 @@ void occli_printHelpMenu_on_console(helpMenu *helpMenuArray[],
}
printf("----------------------------------------------------------"
"-------------------------------------------\n");
printf("%-12s%-12s%-15s%-10s%-15s%-20s%-15s\n",
"Subsystem", "Component", "SubComponent", "MsgType",
"ActionType", "Parameter", "Arguments");
"-------------------------------------------\n");
printf("%-12s%-12s%-15s%-10s%-15s%-20s%-15s\n", "Subsystem",
"Component", "SubComponent", "MsgType", "ActionType",
"Parameter", "Arguments");
printf("----------------------------------------------------------"
"-------------------------------------------\n");
for(printIndex = 0; printIndex < index; printIndex++) {
"-------------------------------------------\n");
for (printIndex = 0; printIndex < index; printIndex++) {
printf("%-12s%-12s%-15s%-10s%-15s%-20s%-15s\n",
helpMenuArray[printIndex]->subSystem,
helpMenuArray[printIndex]->component,
helpMenuArray[printIndex]->subComponent,
helpMenuArray[printIndex]->msgType,
helpMenuArray[printIndex]->actionType,
helpMenuArray[printIndex]->parameter,
helpMenuArray[printIndex]->arguments);
helpMenuArray[printIndex]->subSystem,
helpMenuArray[printIndex]->component,
helpMenuArray[printIndex]->subComponent,
helpMenuArray[printIndex]->msgType,
helpMenuArray[printIndex]->actionType,
helpMenuArray[printIndex]->parameter,
helpMenuArray[printIndex]->arguments);
}
printf("----------------------------------------------------------"
"-------------------------------------------\n");
"-------------------------------------------\n");
} else if (strcmp(subSystem, "debug") == 0) {
/*Printing for debug subSystem */
printf("\nGet Example :\n");
@@ -245,49 +244,47 @@ void occli_printHelpMenu_on_console(helpMenu *helpMenuArray[],
printf("debug.I2C.bus0 set 104 2 58 1\n");
printf("debug.gbc.ioexpanderx70 set 1 0\n");
printf("\n-------------------------------------------------------"
"----------------------------------------"
"---------\n");
printf("%-15s%-15s%-15s%-15s%-15s%-20s\n",
"Subsystem", "Component", "SubComponent", "MsgType",
"ActionType", "Arguments");
"----------------------------------------"
"---------\n");
printf("%-15s%-15s%-15s%-15s%-15s%-20s\n", "Subsystem", "Component",
"SubComponent", "MsgType", "ActionType", "Arguments");
printf("-------------------------------------------------------"
"----------------------------------------"
"---------\n");
for(printIndex = 0; printIndex < index; printIndex++) {
"----------------------------------------"
"---------\n");
for (printIndex = 0; printIndex < index; printIndex++) {
printf("%-15s%-15s%-15s%-15s%-15s%-20s\n",
helpMenuArray[printIndex]->subSystem,
helpMenuArray[printIndex]->component,
helpMenuArray[printIndex]->subComponent,
helpMenuArray[printIndex]->msgType,
helpMenuArray[printIndex]->actionType,
helpMenuArray[printIndex]->arguments);
helpMenuArray[printIndex]->subSystem,
helpMenuArray[printIndex]->component,
helpMenuArray[printIndex]->subComponent,
helpMenuArray[printIndex]->msgType,
helpMenuArray[printIndex]->actionType,
helpMenuArray[printIndex]->arguments);
}
printf("-------------------------------------------------------"
"----------------------------------------"
"---------\n");
"----------------------------------------"
"---------\n");
} else {
/*Printing for all othere subSystem */
/* Dispalay of parameter default value and unit in help menu
* will be take care with common schema factory config
*/
*/
printf("\n------------------------------------------------------------"
"----------------------------------\n");
printf("%-12s%-17s%-18s%-12s%-12s%-23s\n",
"Subsystem", "Component", "SubComponent", "MsgType",
"ActionType", "Parameter");
"----------------------------------\n");
printf("%-12s%-17s%-18s%-12s%-12s%-23s\n", "Subsystem", "Component",
"SubComponent", "MsgType", "ActionType", "Parameter");
printf("\n------------------------------------------------------------"
"----------------------------------\n");
for(printIndex = 0; printIndex < index; printIndex++) {
"----------------------------------\n");
for (printIndex = 0; printIndex < index; printIndex++) {
printf("%-12s%-17s%-18s%-12s%-12s%-23s\n",
helpMenuArray[printIndex]->subSystem,
helpMenuArray[printIndex]->component,
helpMenuArray[printIndex]->subComponent,
helpMenuArray[printIndex]->msgType,
helpMenuArray[printIndex]->actionType,
helpMenuArray[printIndex]->parameter);
helpMenuArray[printIndex]->subSystem,
helpMenuArray[printIndex]->component,
helpMenuArray[printIndex]->subComponent,
helpMenuArray[printIndex]->msgType,
helpMenuArray[printIndex]->actionType,
helpMenuArray[printIndex]->parameter);
}
printf("\n------------------------------------------------------------"
"----------------------------------\n");
"----------------------------------\n");
}
}
@@ -302,7 +299,7 @@ static void occli_free_helpMenupointer(helpMenu *helpMenuArray[])
int32_t mallocIndex = 0;
for (mallocIndex = 0; mallocIndex < OCCLI_HELP_MAX_SIZE; mallocIndex++) {
if(helpMenuArray[mallocIndex])
if (helpMenuArray[mallocIndex])
free(helpMenuArray[mallocIndex]);
}
@@ -327,9 +324,9 @@ int8_t occli_printHelpMenu(const Component *root, char *cmd)
char *token = NULL;
char *cliStr = NULL;
char *cmdBkp = NULL;
char componentStr[OCCLI_CHAR_ARRAY_SIZE] = {0};
char subSys[OCCLI_CHAR_ARRAY_SIZE] = {0};
char subSysComp[OCCLI_CHAR_ARRAY_SIZE] = {0};
char componentStr[OCCLI_CHAR_ARRAY_SIZE] = { 0 };
char subSys[OCCLI_CHAR_ARRAY_SIZE] = { 0 };
char subSysComp[OCCLI_CHAR_ARRAY_SIZE] = { 0 };
int8_t ret = FAILED;
int8_t count = 1;
int8_t subCount = 0;
@@ -341,18 +338,18 @@ int8_t occli_printHelpMenu(const Component *root, char *cmd)
return FAILED;
}
cmdBkp = (char *)malloc (sizeof(cmd));
cmdBkp = (char *)malloc(sizeof(cmd));
if (cmdBkp == NULL) {
logerr("Invalid Memory \n");
return FAILED;
}
strcpy(cmdBkp,cmd);
strcpy(cmdBkp, cmd);
/* Tokenizing string for subsystem and component */
cliStr = strtok(cmd, " ");
if ((cliStr == NULL) || (strstr(cliStr, "help"))) {
printf("%s : Error : Incorrect request\n", cmdBkp);
printf ("Usage : subsystem --help or subsystem.component --help\n");
printf("Usage : subsystem --help or subsystem.component --help\n");
free(cmdBkp);
return FAILED;
} else {
@@ -365,8 +362,8 @@ int8_t occli_printHelpMenu(const Component *root, char *cmd)
count++;
if (count > 2) {
printf("%s : Error : Incorrect request\n", cmdBkp);
printf ("Usage : subsystem --help"
" OR subsystem.component --help\n");
printf("Usage : subsystem --help"
" OR subsystem.component --help\n");
free(cmdBkp);
return FAILED;
}
@@ -387,8 +384,8 @@ int8_t occli_printHelpMenu(const Component *root, char *cmd)
while (subSystem && subSystem->name) {
if (strcmp(subSys, subSystem->name) == 0) {
subCount++;
strncpy((helpMenuArray[index++]->subSystem),
subSystem->name, strlen(subSystem->name));
strncpy((helpMenuArray[index++]->subSystem), subSystem->name,
strlen(subSystem->name));
component = subSystem->components;
while (component && component->name) {
if ((count == 2)) {
@@ -399,16 +396,16 @@ int8_t occli_printHelpMenu(const Component *root, char *cmd)
compCount++;
}
}
strncpy((helpMenuArray[index]->component),
component->name, strlen(component->name));
strncpy((helpMenuArray[index]->component), component->name,
strlen(component->name));
sprintf(subSysComp, "%s.%s", subSystem->name, component->name);
command = component->commands;
ret = occli_fill_data_from_command(command,
helpMenuArray, &index, subSysComp);
ret = occli_fill_data_from_command(command, helpMenuArray,
&index, subSysComp);
devDriver = component->driver;
if (devDriver != NULL) {
ret = occli_fill_data_from_driver(devDriver,
helpMenuArray, &index, subSysComp);
ret = occli_fill_data_from_driver(devDriver, helpMenuArray,
&index, subSysComp);
if (ret == FAILED) {
logerr("\noccli_fill_data_from_driver Error");
occli_free_helpMenupointer(helpMenuArray);
@@ -419,14 +416,14 @@ int8_t occli_printHelpMenu(const Component *root, char *cmd)
subComponent = component->components;
while (subComponent && subComponent->name) {
strncpy((helpMenuArray[index]->subComponent),
subComponent->name, strlen(subComponent->name));
subComponent->name, strlen(subComponent->name));
command = subComponent->commands;
ret = occli_fill_data_from_command(command,
helpMenuArray, &index, subSysComp);
ret = occli_fill_data_from_command(command, helpMenuArray,
&index, subSysComp);
devDriver = subComponent->driver;
if (devDriver != NULL) {
ret = occli_fill_data_from_driver(devDriver,
helpMenuArray, &index, subSysComp);
ret = occli_fill_data_from_driver(
devDriver, helpMenuArray, &index, subSysComp);
if (ret == FAILED) {
logerr("\noccli_fill_data_from_driver Error");
occli_free_helpMenupointer(helpMenuArray);

View File

@@ -25,18 +25,22 @@
#define HISTORY ".occli_history" /* Saved under ${HOME} direcotory */
#define SWAP(s, e) do { \
int32_t t; t = s; s = e; e = t; \
} while (0)
#define SWAP(s, e) \
do { \
int32_t t; \
t = s; \
s = e; \
e = t; \
} while (0)
/* MAX_CLIENTRY represents the maximum entries which autofill can take */
#define OCCLI_MAX_CLISTRING 1000
#define OCCLI_MAX_SUBSTRING 75
#define OCCLI_STRING_MAX_LEN 100
#define OCCLI_CALC_SCHEMA_SIZE 1
#define OCCLI_PARSE_SCHEMA 2
#define MAX_ETHERNET_PORT 4
#define OPENCELLULAR "opencellular# "
#define OCCLI_MAX_CLISTRING 1000
#define OCCLI_MAX_SUBSTRING 75
#define OCCLI_STRING_MAX_LEN 100
#define OCCLI_CALC_SCHEMA_SIZE 1
#define OCCLI_PARSE_SCHEMA 2
#define MAX_ETHERNET_PORT 4
#define OPENCELLULAR "opencellular# "
extern char *rl_line_buffer;
static char *s_allParams[OCCLI_MAX_CLISTRING];
@@ -65,7 +69,7 @@ int8_t occli_trim_extra_spaces(char *string)
length = strlen(string);
end = string + length - 1;
while(end >= string && isblank(*end)) {
while (end >= string && isblank(*end)) {
end--;
}
@@ -79,7 +83,7 @@ int8_t occli_trim_extra_spaces(char *string)
* Input(s) :
* Output(s) : s_strCli
***************************************************************************/
static int8_t occli_copy_text ()
static int8_t occli_copy_text()
{
int8_t ret = FAILED;
int16_t length;
@@ -91,18 +95,18 @@ static int8_t occli_copy_text ()
}
length = rl_point;
s_strCli = (char*)realloc(s_strCli, length + 1);
s_strCli = (char *)realloc(s_strCli, length + 1);
if (s_strCli == NULL) {
printf("\n ERROR: realloc");
} else {
ret = SUCCESS;
strncpy (s_strCli, rl_line_buffer, length);
strncpy(s_strCli, rl_line_buffer, length);
s_strCli[length] = '\0';
}
if (ret == SUCCESS) {
ret = occli_trim_extra_spaces(s_strCli);
ret = occli_trim_extra_spaces(s_strCli);
}
return ret;
@@ -127,8 +131,9 @@ static int8_t occli_init_subSetParams(const char *text)
}
if (s_subSetParams != NULL) {
for (listIdx = 0; (s_subSetParams[listIdx] != NULL &&
listIdx < OCCLI_MAX_SUBSTRING) ; listIdx++) {
for (listIdx = 0;
(s_subSetParams[listIdx] != NULL && listIdx < OCCLI_MAX_SUBSTRING);
listIdx++) {
free(s_subSetParams[listIdx]);
s_subSetParams[listIdx] = NULL;
}
@@ -139,14 +144,14 @@ static int8_t occli_init_subSetParams(const char *text)
while ((paramStr = s_allParams[listIdx])) {
if (strncmp(text, paramStr, len) == 0) {
subsetIdx++;
if(subsetIdx >= OCCLI_MAX_SUBSTRING) {
if (subsetIdx >= OCCLI_MAX_SUBSTRING) {
break;
}
}
listIdx++;
}
for (listIdx= 0; listIdx < subsetIdx; listIdx++) {
for (listIdx = 0; listIdx < subsetIdx; listIdx++) {
s_subSetParams[listIdx] = (char *)calloc(1, OCCLI_STRING_MAX_LEN);
if ((s_subSetParams[listIdx]) == NULL) {
logerr("calloc error");
@@ -163,16 +168,16 @@ static int8_t occli_init_subSetParams(const char *text)
* Input(s) : text, state
* Output(s) :
***************************************************************************/
static char* occli_all_param_generator(const char* text, int32_t state)
static char *occli_all_param_generator(const char *text, int32_t state)
{
char *paramstr = NULL;
char *token = NULL;
char subStr[OCCLI_STRING_MAX_LEN] = {0};
char tempStr[OCCLI_STRING_MAX_LEN] = {0};
char subStr[OCCLI_STRING_MAX_LEN] = { 0 };
char tempStr[OCCLI_STRING_MAX_LEN] = { 0 };
static int32_t s_listidx = 0;
static int32_t s_subSetIdx = 0;
static int32_t s_len = 0;
int8_t index = 0 ;
int8_t index = 0;
bool isEntryFound = false;
if (text == NULL) {
@@ -211,18 +216,18 @@ static char* occli_all_param_generator(const char* text, int32_t state)
if (strncmp(text, "", 1) == 0) {
/* case where the user hasn't entered any string */
sprintf(tempStr, "%s", token);
} else if(strncmp(paramstr + s_len, "." , 1) == 0) {
} else if (strncmp(paramstr + s_len, ".", 1) == 0) {
/*
* case where the user has entered complete string
* for either subsystem/component (ie) "system"
*/
sprintf(tempStr, "%s.%s", text,token);
sprintf(tempStr, "%s.%s", text, token);
} else {
/*
* case where the user has entered subset of the string
* for example "sys"
*/
sprintf(tempStr, "%s%s", text,token);
sprintf(tempStr, "%s%s", text, token);
}
}
/*
@@ -235,7 +240,7 @@ static char* occli_all_param_generator(const char* text, int32_t state)
break;
}
}
if(isEntryFound != true) {
if (isEntryFound != true) {
strcpy(s_subSetParams[s_subSetIdx], tempStr);
s_subSetIdx++;
return strdup(s_subSetParams[s_subSetIdx - 1]);
@@ -250,10 +255,10 @@ static char* occli_all_param_generator(const char* text, int32_t state)
* Input(s) : text, start, end
* Output(s) :
***************************************************************************/
static char** occli_custom_completion(const char* text, int32_t start,
int32_t end)
static char **occli_custom_completion(const char *text, int32_t start,
int32_t end)
{
char** matches = NULL;
char **matches = NULL;
int8_t ret = FAILED;
if (text == NULL) {
@@ -284,7 +289,7 @@ static char** occli_custom_completion(const char* text, int32_t start,
* Output(s) : deststrPtr
***************************************************************************/
static int8_t occli_strjoin(char **deststrPtr, const char *srcstr,
const char *delimstr)
const char *delimstr)
{
char *tmp;
const int32_t alloclen = OCCLI_STRING_SIZE;
@@ -339,9 +344,9 @@ static int8_t occli_strjoin(char **deststrPtr, const char *srcstr,
* Input(s) : pThreadData
* Output(s) :
***************************************************************************/
void * occli_alertthread_messenger_to_ocmw(void *pThreadData)
void *occli_alertthread_messenger_to_ocmw(void *pThreadData)
{
char response[RES_STR_BUFF_SIZE] = {0};
char response[RES_STR_BUFF_SIZE] = { 0 };
int32_t ret = 0;
/* Receive the CLI command execution response string from OCMW over UDP
@@ -351,7 +356,8 @@ void * occli_alertthread_messenger_to_ocmw(void *pThreadData)
memset(response, 0, sizeof(response));
ret = occli_recv_alertmsg_from_ocmw(response, sizeof(response));
if (ret < 0) {
printf("occli_recv_alertmsg_from_ocmw failed: error value : %d\n", ret);
printf("occli_recv_alertmsg_from_ocmw failed: error value : %d\n",
ret);
} else {
printf("%s\n", response);
}
@@ -368,15 +374,18 @@ int8_t occli_parse_cliString(char *cliString)
{
int8_t ret = FAILED;
int16_t index = 0;
char tempStr[OCCLI_STRING_MAX_LEN] = {0};
char tempStr[OCCLI_STRING_MAX_LEN] = { 0 };
char *token = NULL;
if (cliString == NULL) {
return ret;
}
strcpy(tempStr, cliString);
token = strtok(tempStr, " ");
for(index = 0; ((index < OCCLI_MAX_CLISTRING) &&
(s_allParams[index] != NULL)); index++) {
for (index = 0;
((index < OCCLI_MAX_CLISTRING) && (s_allParams[index] != NULL));
index++) {
if (strcmp(token, s_allParams[index]) == 0) {
ret = SUCCESS;
break;
@@ -391,8 +400,7 @@ int8_t occli_parse_cliString(char *cliString)
* Input(s) : root, occliData->option
* Output(s) : s_allParams, occliData->totalStr, occliData->sizeNum
***************************************************************************/
int8_t occli_frame_commands(const Component *root,
OCCLI_ARRAY_PARAM *occliData)
int8_t occli_frame_commands(const Component *root, OCCLI_ARRAY_PARAM *occliData)
{
const Component *subSystem = root;
const Component *component = subSystem->components;
@@ -400,9 +408,7 @@ int8_t occli_frame_commands(const Component *root,
const Command *command = NULL;
const Driver *driver = NULL;
if ((root == NULL) ||
(occliData == NULL)) {
if ((root == NULL) || (occliData == NULL)) {
logerr("Invalid Memory \n");
return FAILED;
}
@@ -413,14 +419,13 @@ int8_t occli_frame_commands(const Component *root,
component = subSystem->components;
while (component && component->name) {
command = component->commands;
while (command &&
command->name) {
while (command && command->name) {
if (occliData->option == OCCLI_CALC_SCHEMA_SIZE) {
occliData->sizeNum += 1;
} else {
snprintf(s_allParams[occliData->totalStr++],
OCCLI_SNPRINTF_MAX_LEN, "%s.%s.%s",
subSystem->name, component->name, command->name);
OCCLI_SNPRINTF_MAX_LEN, "%s.%s.%s",
subSystem->name, component->name, command->name);
}
command += 1;
}
@@ -435,17 +440,16 @@ int8_t occli_frame_commands(const Component *root,
component = subSystem->components;
while (component && component->name) {
driver = component->driver;
if(driver != NULL) {
if (driver != NULL) {
command = driver->commands;
while (command &&
command->name) {
while (command && command->name) {
if (occliData->option == OCCLI_CALC_SCHEMA_SIZE) {
occliData->sizeNum += 1;
} else {
snprintf(s_allParams[occliData->totalStr++],
OCCLI_SNPRINTF_MAX_LEN, "%s.%s.%s",
subSystem->name, component->name,
command->name);
OCCLI_SNPRINTF_MAX_LEN, "%s.%s.%s",
subSystem->name, component->name,
command->name);
}
command += 1;
}
@@ -463,17 +467,16 @@ int8_t occli_frame_commands(const Component *root,
subComponent = component->components;
while (subComponent && subComponent->name) {
driver = subComponent->driver;
if(driver != NULL) {
if (driver != NULL) {
command = driver->commands;
while (command &&
command->name) {
while (command && command->name) {
if (occliData->option == OCCLI_CALC_SCHEMA_SIZE) {
occliData->sizeNum += 1;
} else {
snprintf(s_allParams[occliData->totalStr++],
OCCLI_STRING_MAX_LEN, "%s.%s.%s.%s",
subSystem->name, component->name,
subComponent->name, command->name);
OCCLI_STRING_MAX_LEN, "%s.%s.%s.%s",
subSystem->name, component->name,
subComponent->name, command->name);
}
command += 1;
}
@@ -493,8 +496,8 @@ int8_t occli_frame_commands(const Component *root,
* Output(s) : ocmwclistr, occliData
***************************************************************************/
int8_t occli_frame_string_from_schemaDriver(const Parameter *param,
OCCLI_ARRAY_PARAM *occliData,
strMsgFrame *strFrame)
OCCLI_ARRAY_PARAM *occliData,
strMsgFrame *strFrame)
{
if ((occliData == NULL) || (param == NULL) || (strFrame == NULL)) {
logerr("Invalid Memory \n");
@@ -505,16 +508,14 @@ int8_t occli_frame_string_from_schemaDriver(const Parameter *param,
occliData->sizeNum += 1;
} else {
if (strlen(strFrame->subcomponent)) {
snprintf(s_allParams[occliData->totalStr++],
OCCLI_SNPRINTF_MAX_LEN, "%s.%s.%s.%s.%s.%s",
strFrame->subsystem, strFrame->component,
strFrame->msgtype, strFrame->subcomponent,
param->name, strFrame->parameter);
snprintf(s_allParams[occliData->totalStr++], OCCLI_SNPRINTF_MAX_LEN,
"%s.%s.%s.%s.%s.%s", strFrame->subsystem,
strFrame->component, strFrame->msgtype,
strFrame->subcomponent, param->name, strFrame->parameter);
} else {
snprintf(s_allParams[occliData->totalStr++],
OCCLI_SNPRINTF_MAX_LEN, "%s.%s.%s.%s.%s",
strFrame->subsystem, strFrame->component,
strFrame->msgtype, param->name, strFrame->parameter);
snprintf(s_allParams[occliData->totalStr++], OCCLI_SNPRINTF_MAX_LEN,
"%s.%s.%s.%s.%s", strFrame->subsystem, strFrame->component,
strFrame->msgtype, param->name, strFrame->parameter);
}
}
return SUCCESS;
@@ -527,8 +528,8 @@ int8_t occli_frame_string_from_schemaDriver(const Parameter *param,
* Output(s) : ocmwclistr, occliData
***************************************************************************/
int8_t occli_frame_string_from_postDriver(const Post *param,
OCCLI_ARRAY_PARAM *occliData,
strMsgFrame *strFrame)
OCCLI_ARRAY_PARAM *occliData,
strMsgFrame *strFrame)
{
if ((occliData == NULL) || (param == NULL) || (strFrame == NULL)) {
logerr("Invalid Memory \n");
@@ -539,16 +540,14 @@ int8_t occli_frame_string_from_postDriver(const Post *param,
occliData->sizeNum += 1;
} else {
if (strlen(strFrame->subcomponent)) {
snprintf(s_allParams[occliData->totalStr++],
OCCLI_SNPRINTF_MAX_LEN, "%s.%s.%s.%s.%s.%s",
strFrame->subsystem, strFrame->component,
strFrame->msgtype, strFrame->subcomponent,
param->name, strFrame->parameter);
snprintf(s_allParams[occliData->totalStr++], OCCLI_SNPRINTF_MAX_LEN,
"%s.%s.%s.%s.%s.%s", strFrame->subsystem,
strFrame->component, strFrame->msgtype,
strFrame->subcomponent, param->name, strFrame->parameter);
} else {
snprintf(s_allParams[occliData->totalStr++],
OCCLI_SNPRINTF_MAX_LEN, "%s.%s.%s.%s.%s",
strFrame->subsystem, strFrame->component,
strFrame->msgtype, param->name, strFrame->parameter);
snprintf(s_allParams[occliData->totalStr++], OCCLI_SNPRINTF_MAX_LEN,
"%s.%s.%s.%s.%s", strFrame->subsystem, strFrame->component,
strFrame->msgtype, param->name, strFrame->parameter);
}
}
return SUCCESS;
@@ -560,8 +559,8 @@ int8_t occli_frame_string_from_postDriver(const Post *param,
* Output(s) : ocmwclistr, occliData
***************************************************************************/
int8_t occli_frame_string_from_schema(const Driver *devDriver,
OCCLI_ARRAY_PARAM *occliData,
strMsgFrame *strFrame)
OCCLI_ARRAY_PARAM *occliData,
strMsgFrame *strFrame)
{
const Post *postParam = NULL;
const Parameter *param = NULL;
@@ -580,7 +579,8 @@ int8_t occli_frame_string_from_schema(const Driver *devDriver,
} else {
strcpy(strFrame->parameter, "get");
}
ret = occli_frame_string_from_postDriver(postParam, occliData, strFrame);
ret =
occli_frame_string_from_postDriver(postParam, occliData, strFrame);
postParam++;
}
@@ -623,10 +623,9 @@ int8_t occli_frame_string(const Component *root, OCCLI_ARRAY_PARAM *occliData)
const Driver *devDriver = NULL;
int8_t ret = 0;
strMsgFrame *strFrame = (strMsgFrame *) malloc(sizeof(strMsgFrame));
strMsgFrame *strFrame = (strMsgFrame *)malloc(sizeof(strMsgFrame));
if ((strFrame == NULL) || (root == NULL) ||
(occliData == NULL)) {
if ((strFrame == NULL) || (root == NULL) || (occliData == NULL)) {
logerr("Invalid Memory \n");
return FAILED;
}
@@ -641,8 +640,8 @@ int8_t occli_frame_string(const Component *root, OCCLI_ARRAY_PARAM *occliData)
strcpy(strFrame->component, component->name);
devDriver = component->driver;
if (devDriver != NULL) {
ret = occli_frame_string_from_schema(devDriver,
occliData, strFrame);
ret = occli_frame_string_from_schema(devDriver, occliData,
strFrame);
if (ret == FAILED) {
return ret;
}
@@ -652,8 +651,8 @@ int8_t occli_frame_string(const Component *root, OCCLI_ARRAY_PARAM *occliData)
strcpy(strFrame->subcomponent, subComponent->name);
devDriver = subComponent->driver;
if (devDriver != NULL) {
ret = occli_frame_string_from_schema(devDriver,
occliData, strFrame);
ret = occli_frame_string_from_schema(devDriver, occliData,
strFrame);
if (ret == FAILED) {
return ret;
}
@@ -678,10 +677,10 @@ int32_t main(int32_t argc, char *argv[])
{
char *line = NULL;
char *clistr = NULL;
char response[RES_STR_BUFF_SIZE] = {0};
char response[RES_STR_BUFF_SIZE] = { 0 };
char historyFile[HIT_FILE_BUFF_SIZE];
char *cmdstr = NULL;
const char* prompt = "opencellular# ";
const char *prompt = "opencellular# ";
int32_t index = 0;
int32_t ret = 0;
pthread_t alertThreadId;
@@ -692,7 +691,7 @@ int32_t main(int32_t argc, char *argv[])
initlog("occli");
memset(&msgFrameParam, 0, sizeof(sMsgParam));
memset (&occliArray, 0, sizeof(OCCLI_ARRAY_PARAM));
memset(&occliArray, 0, sizeof(OCCLI_ARRAY_PARAM));
occliArray.option = OCCLI_CALC_SCHEMA_SIZE;
@@ -708,11 +707,10 @@ int32_t main(int32_t argc, char *argv[])
return FAILED;
}
for (index= 0; index< occliArray.sizeNum; index++) {
if(!(s_allParams[index] = (char *)malloc(OCCLI_STRING_MAX_LEN))) {
for (index = 0; index < occliArray.sizeNum; index++) {
if (!(s_allParams[index] = (char *)malloc(OCCLI_STRING_MAX_LEN))) {
return FAILED;
}
}
occliArray.option = OCCLI_PARSE_SCHEMA;
@@ -735,9 +733,14 @@ int32_t main(int32_t argc, char *argv[])
return FAILED;
}
ret = pthread_create(&alertThreadId, NULL,
occli_alertthread_messenger_to_ocmw, NULL);
if (ret != 0) {
return ret;
}
/* Execute the OC command (argv[1:]) and exit */
if (strcmp("occmd", basename(argv[0])) == 0) {
for (index= 1; index < argc; index++) {
for (index = 1; index < argc; index++) {
if (occli_strjoin(&cmdstr, argv[index], " ") != 0) {
logerr("occli_strjoin error");
break;
@@ -765,17 +768,10 @@ int32_t main(int32_t argc, char *argv[])
}
/* Entering interactive CLI */
else if (strcmp("occli", basename(argv[0])) == 0) {
ret = pthread_create(&alertThreadId, NULL,
occli_alertthread_messenger_to_ocmw, NULL);
if (ret != 0) {
return ret;
}
/* Initialize readline */
using_history();
if ((snprintf(historyFile, HIT_FILE_BUFF_SIZE, "%s/%s", getenv("HOME"),
HISTORY)) < 0) {
HISTORY)) < 0) {
return FAILED;
}
@@ -807,7 +803,7 @@ int32_t main(int32_t argc, char *argv[])
break;
}
/* Print the help manu */
if((strstr(clistr, "help"))) {
if ((strstr(clistr, "help"))) {
if ((strstr(clistr, "--help"))) {
ret = occli_printHelpMenu(sys_schema, clistr);
if (ret == FAILED) {
@@ -816,8 +812,8 @@ int32_t main(int32_t argc, char *argv[])
continue;
} else {
printf("%s : Error : Incorrect request\n", clistr);
printf ("Usage : subsystem --help"
" OR subsystem.component --help\n");
printf("Usage : subsystem --help"
" OR subsystem.component --help\n");
continue;
}
}
@@ -844,13 +840,15 @@ int32_t main(int32_t argc, char *argv[])
write_history(historyFile);
}
for (index= 0; ((s_allParams[index] != NULL) &&
(index < OCCLI_MAX_CLISTRING)); index++) {
for (index = 0;
((s_allParams[index] != NULL) && (index < OCCLI_MAX_CLISTRING));
index++) {
free(s_allParams[index]);
}
for (index= 0; ((s_subSetParams[index] != NULL) &&
(index < OCCLI_MAX_SUBSTRING)); index++) {
for (index = 0;
((s_subSetParams[index] != NULL) && (index < OCCLI_MAX_SUBSTRING));
index++) {
free(s_subSetParams[index]);
}
occli_deinit_comm();

View File

@@ -65,8 +65,8 @@ int32_t occli_init_comm(void)
return ret;
}
if (setsockopt(s_sockFd, SOL_SOCKET, SO_RCVTIMEO,
&timeValObj, sizeof(timeValObj)) < 0) {
if (setsockopt(s_sockFd, SOL_SOCKET, SO_RCVTIMEO, &timeValObj,
sizeof(timeValObj)) < 0) {
logerr("setsockopt failed");
ret = FAILED;
return ret;
@@ -74,7 +74,7 @@ int32_t occli_init_comm(void)
/* For Alert Capture */
s_alertSockFd = socket(OCMW_SOCK_ALERT_DOMAIN, OCMW_SOCK_ALERT_TYPE,
OCMW_SOCK_ALERT_PROTOCOL);
OCMW_SOCK_ALERT_PROTOCOL);
if (s_alertSockFd < 0) {
ret = -errno;
logerr("socket creation error [%d-%s]", errno, strerror(errno));
@@ -93,8 +93,8 @@ int32_t occli_init_comm(void)
}
/* Bind host address to the socket */
ret = bind(s_alertSockFd, (struct sockaddr*) &s_alertServer,
sizeof(s_alertServer));
ret = bind(s_alertSockFd, (struct sockaddr *)&s_alertServer,
sizeof(s_alertServer));
if (ret < 0) {
ret = -errno;
logerr("bind error [%d-%s]", errno, strerror(errno));
@@ -133,8 +133,8 @@ int32_t occli_send_cmd_to_ocmw(const char *cmd, int32_t cmdlen)
strncpy(s_displayStr, cmd, cmdlen);
/* Send the CLI command string to OCMW over UDP socket */
ret = sendto(s_sockFd, cmd, cmdlen, 0,
(const struct sockaddr *) &s_siServer, strLen);
ret = sendto(s_sockFd, cmd, cmdlen, 0, (const struct sockaddr *)&s_siServer,
strLen);
if (ret < 0) {
strerror_r(errno, errstr, OCMW_SOCKET_ERROR_SIZE);
logerr("Error: 'sendto' [%d-%s]", errno, errstr);
@@ -157,8 +157,8 @@ int32_t occli_recv_cmd_resp_from_ocmw(char *resp, int32_t resplen)
/* Receive the CLI command execution response string from OCMW over UDP
socket */
ret = recvfrom(s_sockFd, resp, resplen, 0,
(struct sockaddr*) &s_siServer, (socklen_t*) &strLen);
ret = recvfrom(s_sockFd, resp, resplen, 0, (struct sockaddr *)&s_siServer,
(socklen_t *)&strLen);
if (ret < 0) {
strerror_r(errno, errstr, OCMW_SOCKET_ERROR_SIZE);
logerr("Error: 'recvfrom' [%d-%s]", ret, errstr);
@@ -182,7 +182,7 @@ int32_t occli_recv_alertmsg_from_ocmw(char *resp, int32_t resplen)
/* Receive the Alert Message string from OCMW over UDP socket */
ret = recvfrom(s_alertSockFd, resp, resplen, 0,
(struct sockaddr*) &s_alertServer, (socklen_t*) &strLen);
(struct sockaddr *)&s_alertServer, (socklen_t *)&strLen);
if (ret < 0) {
strerror_r(errno, errstr, OCMW_SOCKET_ERROR_SIZE);
logerr("Error: 'recvfrom' [%d-%s]", ret, errstr);

File diff suppressed because it is too large Load Diff

View File

@@ -30,19 +30,22 @@ extern const Component sys_schema[];
subSystemInfo systemInfo;
extern ocwarePostResultData ocwarePostArray[TEMP_STR_BUFF_SIZE];
extern uint8_t ocwarePostArrayIndex;
extern uint8_t ocwarePostArrayIndex;
int8_t alertRecord = 1;
extern int8_t alertFlag;
ocwarePostReplyCode ocmwReplyCode[] = {
/* Message Type, reply code, Description */
{OCMP_MSG_TYPE_POST, POST_DEV_NOSTATUS , "POST DEV NOSTATUS"},
{OCMP_MSG_TYPE_POST, POST_DEV_MISSING, "DEV MISSING"},
{OCMP_MSG_TYPE_POST, POST_DEV_ID_MISMATCH, "DEV ID MISMATCH"},
{OCMP_MSG_TYPE_POST, POST_DEV_FOUND, "DEV FOUND"},
{OCMP_MSG_TYPE_POST, POST_DEV_CFG_DONE, "CFG DONE"},
{OCMP_MSG_TYPE_POST, POST_DEV_NO_CFG_REQ, "NO CFG REQUIRED"},
{OCMP_MSG_TYPE_POST, POST_DEV_CFG_FAIL, "CFG FAILED"},
{OCMP_MSG_TYPE_POST, POST_DEV_FAULTY, "FAULT"},
{OCMP_MSG_TYPE_POST, POST_DEV_CRITICAL_FAULT, "CRITICAL FAULT"},
{OCMP_MSG_TYPE_POST, POST_DEV_NO_DRIVER_EXIST, "NO DRIVER EXIST"}
{ OCMP_MSG_TYPE_POST, POST_DEV_NOSTATUS, "POST DEV NOSTATUS" },
{ OCMP_MSG_TYPE_POST, POST_DEV_MISSING, "DEV MISSING" },
{ OCMP_MSG_TYPE_POST, POST_DEV_ID_MISMATCH, "DEV ID MISMATCH" },
{ OCMP_MSG_TYPE_POST, POST_DEV_FOUND, "DEV FOUND" },
{ OCMP_MSG_TYPE_POST, POST_DEV_CFG_DONE, "CFG DONE" },
{ OCMP_MSG_TYPE_POST, POST_DEV_NO_CFG_REQ, "NO CFG REQUIRED" },
{ OCMP_MSG_TYPE_POST, POST_DEV_CFG_FAIL, "CFG FAILED" },
{ OCMP_MSG_TYPE_POST, POST_DEV_FAULTY, "FAULT" },
{ OCMP_MSG_TYPE_POST, POST_DEV_CRITICAL_FAULT, "CRITICAL FAULT" },
{ OCMP_MSG_TYPE_POST, POST_DEV_NO_DRIVER_EXIST, "NO DRIVER EXIST" }
};
/******************************************************************************
* Function Name : ocmw_free_global_pointer
@@ -50,10 +53,10 @@ ocwarePostReplyCode ocmwReplyCode[] = {
* global variable
* Input(s) : ptr
* Output(s) :
******************************************************************************/
******************************************************************************/
void ocmw_free_global_pointer(void **ptr)
{
if(*ptr != NULL) {
if (*ptr != NULL) {
free(*ptr);
*ptr = NULL;
}
@@ -65,10 +68,9 @@ void ocmw_free_global_pointer(void **ptr)
* Input(s) : postResult
* Output(s) :
******************************************************************************/
char ocmw_retrieve_post_results_count (ocwarePostResults *postResult)
char ocmw_retrieve_post_results_count(ocwarePostResults *postResult)
{
postResult->count =
sizeof(ocwarePostArray)/sizeof(ocwarePostArray[0]);
postResult->count = sizeof(ocwarePostArray) / sizeof(ocwarePostArray[0]);
return SUCCESS;
}
@@ -78,11 +80,11 @@ char ocmw_retrieve_post_results_count (ocwarePostResults *postResult)
* Input(s) : postResult
* Output(s) :
******************************************************************************/
char ocmw_retrieve_post_results (ocwarePostResults *postResult)
char ocmw_retrieve_post_results(ocwarePostResults *postResult)
{
memcpy(postResult->results, ocwarePostArray,
postResult->count * sizeof(ocwarePostResultData));
memset(ocwarePostArray,0,sizeof(ocwarePostResultData));
postResult->count * sizeof(ocwarePostResultData));
memset(ocwarePostArray, 0, sizeof(ocwarePostResultData));
return SUCCESS;
}
@@ -93,16 +95,16 @@ char ocmw_retrieve_post_results (ocwarePostResults *postResult)
* Input(s) : replyCode
* Output(s) :
******************************************************************************/
char ocmw_retrieve_reply_code_desc (ocwarePostReplyCode *replyCode)
char ocmw_retrieve_reply_code_desc(ocwarePostReplyCode *replyCode)
{
int32_t postSize = 0;
int32_t sysIndex = 0;
postSize = sizeof(ocmwReplyCode)/sizeof(ocmwReplyCode[0]);
postSize = sizeof(ocmwReplyCode) / sizeof(ocmwReplyCode[0]);
for (sysIndex = 0; sysIndex < postSize; sysIndex++) {
if ((ocmwReplyCode[sysIndex].msgtype == replyCode->msgtype) &&
(ocmwReplyCode[sysIndex].replycode == replyCode->replycode)) {
(ocmwReplyCode[sysIndex].replycode == replyCode->replycode)) {
memset(replyCode->desc, 0, OCMW_POST_DESC_SIZE);
strncpy(replyCode->desc, ocmwReplyCode[sysIndex].desc,
strlen(ocmwReplyCode[sysIndex].desc));
@@ -118,8 +120,7 @@ char ocmw_retrieve_reply_code_desc (ocwarePostReplyCode *replyCode)
* Input(s) : subsystem, devsn, status
* Output(s) :
******************************************************************************/
char ocmw_update_post_status(uint8_t subsystem, uint8_t devsn,
uint8_t status)
char ocmw_update_post_status(uint8_t subsystem, uint8_t devsn, uint8_t status)
{
int32_t sysIndex = 0;
for (sysIndex = 0; sysIndex < ocwarePostArrayIndex; sysIndex++) {
@@ -174,7 +175,7 @@ int32_t ocmw_init()
* the msg coming from ethernet ec to ap
*/
ret = pthread_create(&ethMsgPaserThreadId, NULL,
ocmw_thread_ethmsgparser, NULL);
ocmw_thread_ethmsgparser, NULL);
if (ret != 0) {
return ret;
}
@@ -183,7 +184,7 @@ int32_t ocmw_init()
* the msg coming from uart ec to ap
*/
ret = pthread_create(&uartMsgPaserThreadId, NULL,
ocmw_thread_uartmsgparser, NULL);
ocmw_thread_uartmsgparser, NULL);
if (ret != 0) {
logerr("pthread_create() failed.");
}
@@ -194,24 +195,23 @@ int32_t ocmw_init()
/**************************************************************************
* Function Name : ocmw_tokenize_class_str
* Description : This Function used to extract the Subsystem,componentID, Messagetype,
* parameter and Subcomponent from the param string
* Input(s) : str
* Description : This Function used to extract the Subsystem,componentID,
*Messagetype, parameter and Subcomponent from the param string Input(s) : str
* Output(s) : msgFrame
***************************************************************************/
static int32_t ocmw_tokenize_class_str( const int8_t *str,
strMsgFrame *msgFrame, uint8_t msgtype)
static int32_t ocmw_tokenize_class_str(const int8_t *str, strMsgFrame *msgFrame,
uint8_t msgtype)
{
char *token;
int32_t count = 0;
char *tempstr = (char *)malloc(PARAM_STR_MAX_BUFF_SIZE);
char *tempstr = (char *)malloc(PARAM_STR_MAX_BUFF_SIZE);
if(str == NULL)
if (str == NULL)
return FAILED;
memset(tempstr,0,PARAM_STR_MAX_BUFF_SIZE);
memcpy(tempstr, str,PARAM_STR_MAX_BUFF_SIZE);
memset(msgFrame,0,sizeof(strMsgFrame));
memset(tempstr, 0, PARAM_STR_MAX_BUFF_SIZE);
memcpy(tempstr, str, PARAM_STR_MAX_BUFF_SIZE);
memset(msgFrame, 0, sizeof(strMsgFrame));
token = strtok(tempstr, " .");
@@ -219,8 +219,7 @@ static int32_t ocmw_tokenize_class_str( const int8_t *str,
return FAILED;
if (msgtype == OCMP_MSG_TYPE_COMMAND) {
if ((strcmp(token,"set") != 0) &&
((strcmp(token,"get") != 0))) {
if ((strcmp(token, "set") != 0) && ((strcmp(token, "get") != 0))) {
strcpy(msgFrame->parameter, token);
while (token) {
if (count == 1) {
@@ -229,7 +228,7 @@ static int32_t ocmw_tokenize_class_str( const int8_t *str,
strcpy(msgFrame->component, token);
}
token = strtok(NULL, " .");
count ++;
count++;
if (token == NULL)
break;
}
@@ -248,14 +247,13 @@ static int32_t ocmw_tokenize_class_str( const int8_t *str,
strcpy(msgFrame->parameter, token);
}
token = strtok(NULL, " .");
count ++;
count++;
if (token == NULL)
break;
}
if (count == 2) {
strcpy(msgFrame->component, "comp_all");
}
}
} else {
strcpy(msgFrame->subsystem, token);
@@ -266,7 +264,7 @@ static int32_t ocmw_tokenize_class_str( const int8_t *str,
strcpy(msgFrame->msgtype, token);
} else if (count == 3) {
strcpy(msgFrame->subcomponent, token);
} else if(count == 4) {
} else if (count == 4) {
strcpy(msgFrame->parameter, token);
}
token = strtok(NULL, " .");
@@ -276,7 +274,7 @@ static int32_t ocmw_tokenize_class_str( const int8_t *str,
strcpy(msgFrame->parameter, msgFrame->subcomponent);
}
if (strncmp (msgFrame->component, "post", strlen("post")) == 0) {
if (strncmp(msgFrame->component, "post", strlen("post")) == 0) {
strcpy(msgFrame->component, "post");
strcpy(msgFrame->msgtype, "post");
strcpy(msgFrame->parameter, msgFrame->subcomponent);
@@ -293,32 +291,33 @@ static int32_t ocmw_tokenize_class_str( const int8_t *str,
* Input(s) :strTokenArray, msgFrame, ecMsgFrame, paramVal
* Output(s) :
******************************************************************************/
void ocmw_fill_payload_data_for_commands(char * strTokenArray[],
strMsgFrame *msgFrame, OCMPMessageFrame *ecMsgFrame, void* paramVal)
void ocmw_fill_payload_data_for_commands(char *strTokenArray[],
strMsgFrame *msgFrame,
OCMPMessageFrame *ecMsgFrame,
void *paramVal)
{
if (msgFrame == NULL) {
return;
}
// Handling sending data for test module
if (strncmp("testmodule", msgFrame->subsystem,
strlen(msgFrame->subsystem)) == 0 ) {
strlen(msgFrame->subsystem)) == 0) {
if ((strncmp(strTokenArray[1], "send", strlen("send")) == 0) ||
(strncmp(strTokenArray[1], "dial", strlen("dial")) == 0)) {
memcpy(&ecMsgFrame->message.info[0], paramVal,
MAX_PARM_COUNT);
memcpy(&ecMsgFrame->message.info[0], paramVal, MAX_PARM_COUNT);
} else {
memset(ecMsgFrame->message.info, 0, MAX_PARM_COUNT);
}
}
// Handling ethernet packet genrator command
if (strncmp("ethernet", msgFrame->subsystem,
strlen(msgFrame->subsystem)) == 0 ) {
if(strstr(strTokenArray[1], "loopBk")) {
if (strncmp("ethernet", msgFrame->subsystem, strlen(msgFrame->subsystem)) ==
0) {
if (strstr(strTokenArray[1], "loopBk")) {
memcpy(&ecMsgFrame->message.info[0], paramVal, sizeof(uint8_t));
} else if ((strncmp(strTokenArray[1], "en_pktGen",
strlen("en_pktGen")) == 0)) {
memcpy(&ecMsgFrame->message.info[0],
(uint16_t *)paramVal, sizeof(uint16_t));
strlen("en_pktGen")) == 0)) {
memcpy(&ecMsgFrame->message.info[0], (uint16_t *)paramVal,
sizeof(uint16_t));
}
}
}
@@ -328,8 +327,9 @@ void ocmw_fill_payload_data_for_commands(char * strTokenArray[],
* Input(s) :actionType, msgType, paramStr, interface, paramVal
* Output(s) :
******************************************************************************/
int32_t ocmw_msg_packetize_and_send(char * strTokenArray[], uint8_t action,
uint8_t msgType, const int8_t * paramStr, uint8_t interface, void* paramVal)
int32_t ocmw_msg_packetize_and_send(char *strTokenArray[], uint8_t action,
uint8_t msgType, const int8_t *paramStr,
uint8_t interface, void *paramVal)
{
int32_t ret = 0;
int32_t paramValue = 0;
@@ -348,36 +348,34 @@ int32_t ocmw_msg_packetize_and_send(char * strTokenArray[], uint8_t action,
paramValLen = strlen((char *)paramVal);
if (!((msgType == OCMP_MSG_TYPE_COMMAND) &&
((strncmp(strTokenArray[1], "get", strlen("get")) == 0) ||
(strncmp(strTokenArray[1], "set", strlen("get")) == 0)))) {
((strcmp(strTokenArray[1], "get")) ||
(strncmp(strTokenArray[1], "set", strlen("get")) == 0)))) {
if (paramValLen == 1 || paramValLen <= 5) {
logdebug ("Paramvalue is of integer type : %d\n", atoi( paramVal));
}
else {
logdebug("Paramvalue is of integer type : %d\n", atoi(paramVal));
} else {
paramValFlag = 1;
logdebug ("Paramvalue is of string type : %s \n", (char *)paramVal);
logdebug("Paramvalue is of string type : %s \n", (char *)paramVal);
}
} else {
paramValFlag = 1;
logdebug ("Paramvalue is of string type : %s \n", (char *)paramVal);
logdebug("Paramvalue is of string type : %s \n", (char *)paramVal);
}
if (paramStr == NULL) {
logdebug(" Paramstr is NULL \n");
return ret = FAILED;
} else {
ocmw_tokenize_class_str(tempStr,&msgFramestruct,msgType);
ocmw_tokenize_class_str(tempStr, &msgFramestruct, msgType);
if (msgType == OCMP_MSG_TYPE_COMMAND) {
ret = ocmw_parse_command_msgframe(sys_schema, &msgFramestruct,
action, &ecSendBuf);
ret = ocmw_parse_command_msgframe(sys_schema, &msgFramestruct,
action, &ecSendBuf);
} else if (msgType == OCMP_MSG_TYPE_POST) {
strcpy((char*)s_paramInfoBackup,msgFramestruct.parameter);
ret = ocmw_parse_post_msgframe(sys_schema, &msgFramestruct,
action, &ecSendBuf);
strcpy((char *)s_paramInfoBackup, msgFramestruct.parameter);
ret = ocmw_parse_post_msgframe(sys_schema, &msgFramestruct, action,
&ecSendBuf);
} else {
ret = ocmw_parse_msgframe(sys_schema, &msgFramestruct, action,
&ecSendBuf);
&ecSendBuf);
}
if (ret < 0) {
return ret;
@@ -393,7 +391,7 @@ int32_t ocmw_msg_packetize_and_send(char * strTokenArray[], uint8_t action,
/* Frame the Core packet for sending data to ec */
ecCoreMsg.action = ecSendBuf.actionType;
ecCoreMsg.msgtype = ecSendBuf.msgType;
ecCoreMsg.msgtype = ecSendBuf.msgType;
ecCoreMsg.componentID = ecSendBuf.componentId;
ecCoreMsg.parameters = ecSendBuf.paramId;
ecCoreMsg.subsystem = ecSendBuf.subsystem;
@@ -403,35 +401,33 @@ int32_t ocmw_msg_packetize_and_send(char * strTokenArray[], uint8_t action,
ecMsgFrame.message = ecCoreMsg;
/* Populate the Core packet payload */
ecMsgFrame.message.info = (int8_t *) malloc(
sizeof(int8_t) * MAX_PARM_COUNT);
ecMsgFrame.message.info = (int8_t *)malloc(sizeof(int8_t) * MAX_PARM_COUNT);
if (ecMsgFrame.message.info == NULL) {
logdebug("\n Memory allocation failed \n");
return ret = FAILED;
}
memset(ecMsgFrame.message.info, 0, MAX_PARM_COUNT);
if ((msgType == OCMP_MSG_TYPE_POST) &&
(strncmp(strTokenArray[1], "set", strlen("set"))== 0)) {
(strncmp(strTokenArray[1], "set", strlen("set")) == 0)) {
logdebug("OCMP_MSG_TYPE_POST:ENABLE:%s()\n", __func__);
}
if(strncmp(msgFramestruct.subsystem,"debug",strlen("debug")) == 0) {
if (strncmp(msgFramestruct.component,"I2C",
strlen("I2C")) == 0) {
if((strncmp(strTokenArray[1], "get", strlen("get")) == 0)) {
dataSize = 3 * sizeof (int8_t);
if (strncmp(msgFramestruct.subsystem, "debug", strlen("debug")) == 0) {
if (strncmp(msgFramestruct.component, "I2C", strlen("I2C")) == 0) {
if ((strncmp(strTokenArray[1], "get", strlen("get")) == 0)) {
dataSize = 3 * sizeof(int8_t);
} else {
dataSize = sizeof(debugI2CData);
}
} else if (strncmp(msgFramestruct.component,"ethernet",
strlen("ethernet")) == 0) {
if((strncmp(strTokenArray[1], "get", strlen("get")) == 0)) {
dataSize = sizeof (uint16_t);
} else if (strncmp(msgFramestruct.component, "ethernet",
strlen("ethernet")) == 0) {
if ((strncmp(strTokenArray[1], "get", strlen("get")) == 0)) {
dataSize = sizeof(uint16_t);
} else {
dataSize = sizeof(debugMDIOData);
}
} else {
if((strncmp(strTokenArray[1], "get", strlen("get")) == 0)) {
dataSize = sizeof (int8_t);
if ((strncmp(strTokenArray[1], "get", strlen("get")) == 0)) {
dataSize = sizeof(int8_t);
} else {
dataSize = sizeof(debugGPIOData);
}
@@ -440,61 +436,54 @@ int32_t ocmw_msg_packetize_and_send(char * strTokenArray[], uint8_t action,
} else {
dataSize = ecSendBuf.paramSize;
}
if((strncmp(strTokenArray[1], "set", strlen("set")) == 0) &&
(msgType != OCMP_MSG_TYPE_POST)) {
if ((strncmp(strTokenArray[1], "set", strlen("set")) == 0) &&
(msgType != OCMP_MSG_TYPE_POST)) {
pos = ecSendBuf.paramPos;
if (paramValFlag == 0) {
paramValue = atoi( paramVal);
paramValue = atoi(paramVal);
memcpy(&ecMsgFrame.message.info[pos], &paramValue, dataSize);
} else {
if (strncmp(msgFramestruct.component,"I2C",
strlen("I2C")) == 0) {
if (strncmp(msgFramestruct.component, "I2C", strlen("I2C")) == 0) {
ecMsgFrame.message.info[pos] = I2CInfo.slaveAddress;
ecMsgFrame.message.info[pos + 1] =
I2CInfo.numOfBytes;
ecMsgFrame.message.info[pos + 2] =
I2CInfo.regAddress;
ecMsgFrame.message.info[pos + 1] = I2CInfo.numOfBytes;
ecMsgFrame.message.info[pos + 2] = I2CInfo.regAddress;
if (I2CInfo.numOfBytes == 1) {
ecMsgFrame.message.info[pos + 3] =
(uint8_t)I2CInfo.regValue;
(uint8_t)I2CInfo.regValue;
} else {
ecMsgFrame.message.info[pos + 4] =
(uint8_t)(I2CInfo.regValue & 0xff);
(uint8_t)(I2CInfo.regValue & 0xff);
ecMsgFrame.message.info[pos + 3] =
(uint8_t)
((I2CInfo.regValue & 0xff00) >> 8);
(uint8_t)((I2CInfo.regValue & 0xff00) >> 8);
}
} else if (strncmp(msgFramestruct.component,"ethernet",
strlen("ethernet")) == 0) {
ecMsgFrame.message.info[pos] = (uint8_t)
(MDIOInfo.regAddress & 0xff);
ecMsgFrame.message.info[pos + 1] = (uint8_t)
((MDIOInfo.regAddress & 0xff00) >> 8);
} else if (strncmp(msgFramestruct.component, "ethernet",
strlen("ethernet")) == 0) {
ecMsgFrame.message.info[pos] =
(uint8_t)(MDIOInfo.regAddress & 0xff);
ecMsgFrame.message.info[pos + 1] =
(uint8_t)((MDIOInfo.regAddress & 0xff00) >> 8);
ecMsgFrame.message.info[pos + 2] =
(uint8_t)(MDIOInfo.regValue & 0xff);
(uint8_t)(MDIOInfo.regValue & 0xff);
ecMsgFrame.message.info[pos + 3] =
(uint8_t)
((MDIOInfo.regValue & 0xff00) >> 8);
(uint8_t)((MDIOInfo.regValue & 0xff00) >> 8);
} else {
memcpy(&ecMsgFrame.message.info[pos], (char *) paramVal,
paramValLen);
memcpy(&ecMsgFrame.message.info[pos], (char *)paramVal,
paramValLen);
}
}
}
if((strncmp(strTokenArray[1], "get", strlen("get")) == 0) &&
(ecMsgFrame.message.subsystem == DEBUG_SUBSYSTEM_NBR)) {
if ((strncmp(strTokenArray[1], "get", strlen("get")) == 0) &&
(ecMsgFrame.message.subsystem == DEBUG_SUBSYSTEM_NBR)) {
pos = ecSendBuf.paramPos;
memcpy(&ecMsgFrame.message.info[pos], (char *) paramVal,
paramValLen);
memcpy(&ecMsgFrame.message.info[pos], (char *)paramVal, paramValLen);
}
//Fill payload data for commands
// Fill payload data for commands
ocmw_fill_payload_data_for_commands(&strTokenArray[0], &msgFramestruct,
&ecMsgFrame, paramVal);
&ecMsgFrame, paramVal);
if (!((msgType == OCMP_MSG_TYPE_POST) &&
(strncmp(strTokenArray[1], "get", strlen("get")) == 0))) {
(strncmp(strTokenArray[1], "get", strlen("get")) == 0))) {
ocmw_send_msg(ecMsgFrame, interface);
}
@@ -507,9 +496,8 @@ int32_t ocmw_msg_packetize_and_send(char * strTokenArray[], uint8_t action,
loopCountSend = systemInfo.Info[0].number;
loopCountPost = systemInfo.Info[0].number;
while(loopCountSend < s_totalSubsystem) {
memset(&(ecMsgFrame.message.info[0]),
loopCountSend, 1);
while (loopCountSend < s_totalSubsystem) {
memset(&(ecMsgFrame.message.info[0]), loopCountSend, 1);
/* Send the message to ec */
ocmw_send_msg(ecMsgFrame, interface);
loopCountSend++;
@@ -562,7 +550,7 @@ int32_t ocmw_msg_packetize_and_send(char * strTokenArray[], uint8_t action,
* Input(s) : pthreadData
* Output(s) :
******************************************************************************/
void * ocmw_thread_uartmsgparser(void *pthreadData)
void *ocmw_thread_uartmsgparser(void *pthreadData)
{
logdebug("Uart task created \n");
while (1) {
@@ -579,14 +567,14 @@ void * ocmw_thread_uartmsgparser(void *pthreadData)
* Input(s) : pthreadData
* Output(s) :
******************************************************************************/
void * ocmw_thread_ethmsgparser(void *pthreadData)
void *ocmw_thread_ethmsgparser(void *pthreadData)
{
int8_t ethRecvBuf[OCMP_MSG_SIZE] = {0};
int8_t ethRecvBuf[OCMP_MSG_SIZE] = { 0 };
logdebug("Ethernet task created \n");
while (1) {
memset(ethRecvBuf, 0, sizeof(ethRecvBuf));
ocmw_recv_eth_msgfrom_ec(ethRecvBuf, sizeof(ethRecvBuf),OCMW_EC_DEV);
ocmw_recv_eth_msgfrom_ec(ethRecvBuf, sizeof(ethRecvBuf), OCMW_EC_DEV);
ocmw_ec_msgparser();
}
}
@@ -610,58 +598,58 @@ void ocmw_ec_msgparser(void)
int32_t sendPktNonpayloadSize = 0;
sMsgParam dmsgFrameParam;
OCMPMessageFrame ecReceivedMsg;
alertRecord = 1;
sendPktNonpayloadSize = (sizeof(OCMPMessage) - sizeof(void *)
+ sizeof(OCMPHeader));
sendPktNonpayloadSize =
(sizeof(OCMPMessage) - sizeof(void *) + sizeof(OCMPHeader));
ecReceivedMsg.message.info = (void *) malloc(
sizeof(char) * MAX_PARM_COUNT);
ecReceivedMsg.message.info = (void *)malloc(sizeof(char) * MAX_PARM_COUNT);
if (ecReceivedMsg.message.info == NULL) {
logerr("Memory allocation failed for "
"ecReceivedMsg.message.info \n");
"ecReceivedMsg.message.info \n");
return;
}
/* parse the data packet */
memcpy((void *) &ecReceivedMsg, (void *) mcuMsgBuf, sendPktNonpayloadSize);
memcpy((void *)&ecReceivedMsg, (void *)mcuMsgBuf, sendPktNonpayloadSize);
memcpy(ecReceivedMsg.message.info, &mcuMsgBuf[sendPktNonpayloadSize],
MAX_PARM_COUNT);
MAX_PARM_COUNT);
msgType = ecReceivedMsg.message.msgtype;
actionType = ecReceivedMsg.message.action;
paramInfo = ecReceivedMsg.message.parameters;
/*
* TODO:Temporary fix for handling alerts
*/
if (msgType == OCMP_MSG_TYPE_ALERT) {
free(ecReceivedMsg.message.info);
return;
}
printf("Received from ec :\n");
for (indexCount = 0; indexCount < OCMP_MSG_SIZE; indexCount++) {
printf("0x%x ", mcuMsgBuf[indexCount]);
}
printf("\n");
/*
* Alerts handling
*/
if ((msgType == OCMP_MSG_TYPE_ALERT) || (alertFlag > 0)) {
ocmw_handle_alert_msg(sys_schema, &ecReceivedMsg, &alertRecord);
responseCount++;
ocmw_free_global_pointer((void **)&ecSendBufBkp);
return;
}
/* In case of timeout, return from the thread
* without processing the data to avoid sync issue.
*/
if (s_semTimeOut) {
s_semTimeOut = 0;
ocmw_free_global_pointer((void**)&ecSendBufBkp);
ocmw_free_global_pointer((void **)&ecSendBufBkp);
return;
}
if ((msgType == OCMP_MSG_TYPE_POST) &&
strcmp((char*)s_paramInfoBackup,"set") == 0) {
strcmp((char *)s_paramInfoBackup, "set") == 0) {
if (actionType == OCMP_AXN_TYPE_REPLY) {
responseCount++;
}
/* Release the lock on which cli is waiting */
ocmw_free_global_pointer((void**)&ecSendBufBkp);
ocmw_free_global_pointer((void **)&ecSendBufBkp);
sem_post(&semCliReturn);
return;
}
@@ -669,7 +657,7 @@ void ocmw_ec_msgparser(void)
/* Release the lock on the POST msgtype semaphore */
if (msgType == OCMP_MSG_TYPE_POST) {
if (actionType != OCMP_AXN_TYPE_REPLY) {
ocmw_free_global_pointer((void**)&ecSendBufBkp);
ocmw_free_global_pointer((void **)&ecSendBufBkp);
ret = sem_post(&semCommandPost);
if (ret != 0) {
perror("sem_wait");
@@ -680,15 +668,15 @@ void ocmw_ec_msgparser(void)
for (; loopCountPost < s_totalSubsystem;) {
/* Waiting on the lock to be released by receiving thread */
for (indexCount = 0; indexCount < paramInfo; indexCount++) {
subsystemPost = ecReceivedMsg.message.info[indexCount
* POST_MAIN_PAYLOAD_SIZE
+ POST_MAIN_PAYLOAD_SUBSYSTEM_OFFSET];
devsn = ecReceivedMsg.message.info[indexCount
* POST_MAIN_PAYLOAD_SIZE
+ POST_MAIN_PAYLOAD_DEVSN_OFFSET];
status = ecReceivedMsg.message.info[indexCount
* POST_MAIN_PAYLOAD_SIZE
+ POST_MAIN_PAYLOAD_STATUS_OFFSET];
subsystemPost = ecReceivedMsg.message
.info[indexCount * POST_MAIN_PAYLOAD_SIZE +
POST_MAIN_PAYLOAD_SUBSYSTEM_OFFSET];
devsn = ecReceivedMsg.message
.info[indexCount * POST_MAIN_PAYLOAD_SIZE +
POST_MAIN_PAYLOAD_DEVSN_OFFSET];
status = ecReceivedMsg.message
.info[indexCount * POST_MAIN_PAYLOAD_SIZE +
POST_MAIN_PAYLOAD_STATUS_OFFSET];
ret = ocmw_update_post_status(subsystemPost, devsn, status);
}
@@ -703,7 +691,7 @@ void ocmw_ec_msgparser(void)
} else {
/* Release the lock on which watchdog thread is waiting */
responseCount++;
ocmw_free_global_pointer((void**)&ecSendBufBkp);
ocmw_free_global_pointer((void **)&ecSendBufBkp);
sem_post(&semCliReturn);
}
return;
@@ -736,8 +724,8 @@ int32_t ocmw_send_msg(OCMPMessageFrame ecMsgFrame, uint8_t interface)
case OCMP_COMM_IFACE_UART:
case OCMP_COMM_IFACE_USB:
/* Send the packetize data to ec through uart*/
ret = ocmw_send_uart_msg_to_ec((uint8_t *) &ecMsgFrame,
OCMP_MSG_SIZE);
ret =
ocmw_send_uart_msg_to_ec((uint8_t *)&ecMsgFrame, OCMP_MSG_SIZE);
break;
case OCMP_COMM_IFACE_ETHERNET:
@@ -748,12 +736,24 @@ int32_t ocmw_send_msg(OCMPMessageFrame ecMsgFrame, uint8_t interface)
sentDev = OCMW_EC_DEV;
#endif
/* Send the packetize data to ec through ethernet*/
ret = ocmw_send_eth_msgto_ec((int8_t *) &ecMsgFrame,
OCMP_MSG_SIZE, sentDev);
ret = ocmw_send_eth_msgto_ec((int8_t *)&ecMsgFrame, OCMP_MSG_SIZE,
sentDev);
#ifdef INTERFACE_STUB_EC
memset(ethRecvBuf, 0, sizeof(ethRecvBuf));
ocmw_recv_eth_msgfrom_ec(ethRecvBuf, sizeof(ethRecvBuf), OCMW_EC_STUB_DEV);
ocmw_ec_msgparser();
if (alertFlag > 0) {
while (1) {
memset(ethRecvBuf, 0, sizeof(ethRecvBuf));
ocmw_recv_eth_msgfrom_ec(ethRecvBuf, sizeof(ethRecvBuf),
OCMW_EC_STUB_DEV);
ocmw_ec_msgparser();
if (alertRecord == 0)
break;
}
} else {
memset(ethRecvBuf, 0, sizeof(ethRecvBuf));
ocmw_recv_eth_msgfrom_ec(ethRecvBuf, sizeof(ethRecvBuf),
OCMW_EC_STUB_DEV);
ocmw_ec_msgparser();
}
#endif
break;

View File

@@ -17,8 +17,8 @@
#include <ocmw_eth_comm.h>
#include <ocmw_socket_comm.h>
#define OCMW_ERR_STR_LEN 80
#define OCWARE_STUB_TIMEOUT_PERIOD 12
#define OCMW_ERR_STR_LEN 80
#define OCWARE_STUB_TIMEOUT_PERIOD 12
extern uint8_t mcuMsgBuf[OCMP_MSG_SIZE];
@@ -40,10 +40,10 @@ int32_t ocmw_init_eth_comm(int32_t sentDev)
struct timeval timeValObj;
timeValObj.tv_sec = OCWARE_STUB_TIMEOUT_PERIOD;
timeValObj.tv_usec = 0;
if (sentDev == OCMW_EC_DEV){
/* Create socket */
if (sentDev == OCMW_EC_DEV) {
/* Create socket */
comSockfd = socket(OCMW_ETH_SOCK_DOMAIN, OCMW_ETH_SOCK_TYPE,
OCMW_ETH_SOCK_PROTOCOL);
OCMW_ETH_SOCK_PROTOCOL);
if (comSockfd < 0) {
rc = -errno;
logerr("socket creation error [%d-%s]", errno, strerror(errno));
@@ -59,8 +59,8 @@ int32_t ocmw_init_eth_comm(int32_t sentDev)
rc = -1;
}
rc = connect(comSockfd, (struct sockaddr *) &sicomServer,
sizeof(sicomServer));
rc = connect(comSockfd, (struct sockaddr *)&sicomServer,
sizeof(sicomServer));
if (rc != 0) {
perror("socket connect failed:");
}
@@ -73,7 +73,7 @@ int32_t ocmw_init_eth_comm(int32_t sentDev)
} else {
/* Create socket */
stub_sockfd = socket(OCMW_SOCK_STUB_DOMAIN, OCMW_SOCK_STUB_TYPE,
OCMW_SOCK_STUB_PROTOCOL);
OCMW_SOCK_STUB_PROTOCOL);
if (stub_sockfd < 0) {
rc = -errno;
logerr("socket creation error [%d-%s]", errno, strerror(errno));
@@ -91,7 +91,7 @@ int32_t ocmw_init_eth_comm(int32_t sentDev)
}
if (setsockopt(stub_sockfd, SOL_SOCKET, SO_RCVTIMEO, &timeValObj,
sizeof(timeValObj)) < 0) {
sizeof(timeValObj)) < 0) {
logerr("setsockopt failed");
rc = -1;
return rc;
@@ -113,9 +113,9 @@ int32_t ocmw_init_eth_comm(int32_t sentDev)
* Input(s) :
* Output(s) :
***************************************************************************/
int32_t ocmw_deinit_eth_comm( int sentDev)
int32_t ocmw_deinit_eth_comm(int sentDev)
{
if (sentDev == OCMW_EC_DEV){
if (sentDev == OCMW_EC_DEV) {
close(comSockfd);
comSockfd = 0; /* Close the IPC socket */
} else {
@@ -150,15 +150,15 @@ int32_t ocmw_send_eth_msgto_ec(const int8_t *cmd, int32_t cmdlen, int sentDev)
return -EMSGSIZE;
}
ecMsgFrame = (OCMPMessageFrame *) cmd;
sendPktNonpayloadSize = (sizeof(OCMPMessage) - sizeof(void *)
+ sizeof(OCMPHeader));
ecMsgFrame = (OCMPMessageFrame *)cmd;
sendPktNonpayloadSize =
(sizeof(OCMPMessage) - sizeof(void *) + sizeof(OCMPHeader));
/* create message frame */
memset(buf, 0, sizeof(buf));
memcpy(buf, ecMsgFrame, sendPktNonpayloadSize);
memcpy(&buf[sendPktNonpayloadSize], ((ecMsgFrame->message).info),
MAX_PARM_COUNT);
MAX_PARM_COUNT);
#ifndef MSG_LOG
printf(" \n send_msg_to_ec \n");
for (loopCount = 0; loopCount < OCMP_MSG_SIZE; loopCount++) {
@@ -167,7 +167,7 @@ int32_t ocmw_send_eth_msgto_ec(const int8_t *cmd, int32_t cmdlen, int sentDev)
printf("\n");
#endif /* MSG_LOG */
if (sentDev == OCMW_EC_DEV){
if (sentDev == OCMW_EC_DEV) {
rc = send(comSockfd, buf, OCMP_MSG_SIZE, 0);
if (rc < 0) {
strerror_r(errno, errstr, errstrLen);
@@ -175,7 +175,7 @@ int32_t ocmw_send_eth_msgto_ec(const int8_t *cmd, int32_t cmdlen, int sentDev)
}
} else {
rc = sendto(stub_sockfd, buf, OCMP_MSG_SIZE, 0,
(struct sockaddr *) &stub_server, sizeof(stub_server) );
(struct sockaddr *)&stub_server, sizeof(stub_server));
if (rc < 0) {
strerror_r(errno, errstr, errstrLen);
logerr("Error: 'send' [%d-%s]", errno, errstr);
@@ -215,8 +215,7 @@ int32_t ocmw_recv_eth_msgfrom_ec(int8_t *resp, int32_t resplen, int sentDev)
#endif
#ifdef INTERFACE_STUB_EC
rc = recvfrom(stub_sockfd, resp, OCMP_MSG_SIZE, 0,
(struct sockaddr *) &stub_server,
(socklen_t*)&dataLen);
(struct sockaddr *)&stub_server, (socklen_t *)&dataLen);
if (rc < 0) {
strerror_r(rc, errstr, errstrLen);
logerr("Error: 'recv' [%d-%s]", rc, errstr);

View File

@@ -16,7 +16,7 @@
#include <logger.h>
#include <ocmw_occli_comm.h>
#define SIZE_INT sizeof (int32_t)
#define SIZE_INT sizeof(int32_t)
int8_t eepromStatusFlag = 0;
@@ -45,7 +45,7 @@ inline int32_t ocmw_sem_wait_nointr(sem_t *sem)
* Output(s) :
******************************************************************************/
inline int32_t ocmw_sem_timedwait_nointr(sem_t *sem,
const struct timespec *timeout)
const struct timespec *timeout)
{
while (sem_timedwait(sem, timeout))
if (errno == EINTR)
@@ -62,7 +62,7 @@ inline int32_t ocmw_sem_timedwait_nointr(sem_t *sem,
* Output(s) : dataSize, pos
******************************************************************************/
void ocmw_dataparsing_from_db(int32_t paramIndex, int32_t *paramSizebuf,
int32_t *dataSize, int32_t *pos)
int32_t *dataSize, int32_t *pos)
{
int32_t count;
int32_t paramIdPresence;
@@ -80,7 +80,7 @@ void ocmw_dataparsing_from_db(int32_t paramIndex, int32_t *paramSizebuf,
*pos = 0;
for (count = 0; count < MAX_PARM_COUNT; count++) {
paramIdPresence = (paramIndex) / ((int) pow(2, count));
paramIdPresence = (paramIndex) / ((int)pow(2, count));
if (paramIdPresence == 1) {
break;
}
@@ -100,8 +100,7 @@ void ocmw_dataparsing_from_db(int32_t paramIndex, int32_t *paramSizebuf,
* Input(s) : input, bufParamStruct
* Output(s) :
******************************************************************************/
void ocmw_dataparsing_from_ec(ocmwSendRecvBuf *input,
bufParam * bufParamStruct)
void ocmw_dataparsing_from_ec(ocmwSendRecvBuf *input, bufParam *bufParamStruct)
{
int32_t count = 0;
int32_t paramIdPresence = 0;
@@ -120,11 +119,11 @@ void ocmw_dataparsing_from_ec(ocmwSendRecvBuf *input,
int32_t *paramSizebuf = input->paramSizebuf;
for (count = 0; count < numOfele; count++) {
bufParamStruct[count].paramindex = (paramInfo & ((int32_t) pow(2,
count + index)));
bufParamStruct[count].paramindex =
(paramInfo & ((int32_t)pow(2, count + index)));
paramIdPresence = bufParamStruct[count].paramindex / pow(2,
count + index);
paramIdPresence =
bufParamStruct[count].paramindex / pow(2, count + index);
if (paramIdPresence == 0) {
paramidSize = 0;
@@ -137,15 +136,15 @@ void ocmw_dataparsing_from_ec(ocmwSendRecvBuf *input,
bufParamStruct[count].paramval = 0;
break;
case CHAR:
bufParamStruct[count].paramval = *((int8_t *) &pbuf[pos]);
bufParamStruct[count].paramval = *((int8_t *)&pbuf[pos]);
break;
case SHORT:
bufParamStruct[count].paramval = *((int16_t *) &pbuf[pos]);
bufParamStruct[count].paramval = *((int16_t *)&pbuf[pos]);
break;
case INT:
bufParamStruct[count].paramval = *((int32_t *) &pbuf[pos]);
bufParamStruct[count].paramval = *((int32_t *)&pbuf[pos]);
break;
default:

View File

@@ -32,8 +32,8 @@ uint8_t mcuMsgBuf[OCMP_MSG_SIZE];
***************************************************************************/
int32_t main(int32_t argc, char **argv)
{
char cmdstr[CMD_STR_BUFF_SIZE] = {0};
char response[RES_STR_BUFF_SIZE] = {0};
char cmdstr[CMD_STR_BUFF_SIZE] = { 0 };
char response[RES_STR_BUFF_SIZE] = { 0 };
int32_t ret = 0;
/* Initialize logging */
@@ -54,16 +54,16 @@ int32_t main(int32_t argc, char **argv)
#ifdef INTERFACE_ETHERNET
ret = ocmw_init_eth_comm(OCMW_EC_DEV);
if(ret != 0) {
printf ("ocmw_init_eth_comm() failed \n");
if (ret != 0) {
printf("ocmw_init_eth_comm() failed \n");
return FAILED;
}
#endif /* INTERFACE_ETHERNET */
#ifdef INTERFACE_STUB_EC
ret = ocmw_init_eth_comm(OCMW_EC_STUB_DEV);
if(ret != 0) {
printf ("init_eth_comm() failed \n");
if (ret != 0) {
printf("init_eth_comm() failed \n");
return FAILED;
}
#endif /* INTERFACE_ETHERNET */

7
firmware/host/ocmw/ocmw_msgproc.c Executable file → Normal file
View File

@@ -21,8 +21,8 @@
* Input(s) : strTokenArray, action, msgtype, paramstr
* Output(s) : paramvalue
***************************************************************************/
int ocmw_msgproc_send_msg(char * strTokenArray[], uint8_t action,
int8_t msgtype, const int8_t* paramstr, void *paramvalue)
int ocmw_msgproc_send_msg(char *strTokenArray[], uint8_t action, int8_t msgtype,
const int8_t *paramstr, void *paramvalue)
{
int32_t ret = 0;
uint8_t interface = 0;
@@ -34,10 +34,9 @@ int ocmw_msgproc_send_msg(char * strTokenArray[], uint8_t action,
interface = OCMP_COMM_IFACE_UART;
#endif /* INTERFACE_ETHERNET */
ret = ocmw_msg_packetize_and_send(&strTokenArray[0], action, msgtype,
paramstr, interface, paramvalue);
paramstr, interface, paramvalue);
if (ret != 0) {
logerr("ocmw_msg_packetize_and_send failed \n");
}
return ret;
}

View File

@@ -57,7 +57,7 @@ int32_t ocmw_init_occli_comm()
s_siServer.sin_port = htons(OCMW_SOCK_SERVER_PORT);
/* Bind host address to the socket */
ret = bind(s_ssockFd, (struct sockaddr*) &s_siServer, sizeof(s_siServer));
ret = bind(s_ssockFd, (struct sockaddr *)&s_siServer, sizeof(s_siServer));
if (ret < 0) {
ret = -errno;
logerr("bind error [%d-%s]", errno, strerror(errno));
@@ -71,8 +71,8 @@ int32_t ocmw_init_occli_comm()
/***** Alert related socket init *****/
/* Create socket */
s_ssockfdAlert = socket(OCMW_SOCK_DOMAIN, OCMW_SOCK_TYPE,
OCMW_SOCK_PROTOCOL);
s_ssockfdAlert =
socket(OCMW_SOCK_DOMAIN, OCMW_SOCK_TYPE, OCMW_SOCK_PROTOCOL);
if (s_ssockfdAlert < 0) {
ret = -errno;
logerr("socket creation error [%d-%s]", errno, strerror(errno));
@@ -123,7 +123,7 @@ int32_t ocmw_deinit_occli_alert_comm(void)
* Input(s) : buf, buflen
* Output(s) :
***************************************************************************/
int32_t ocmw_send_clicmd_resp_to_occli(const char* buf, int32_t buflen)
int32_t ocmw_send_clicmd_resp_to_occli(const char *buf, int32_t buflen)
{
char errstr[OCMW_SOCKET_ERROR_SIZE];
int32_t ret = 0;
@@ -131,7 +131,7 @@ int32_t ocmw_send_clicmd_resp_to_occli(const char* buf, int32_t buflen)
/* Send the message buffer over IPC */
ret = sendto(s_ssockFd, buf, buflen, 0,
(const struct sockaddr *) &s_siClient, destLen);
(const struct sockaddr *)&s_siClient, destLen);
if (ret == -1) {
strerror_r(errno, errstr, OCMW_SOCKET_ERROR_SIZE);
logerr("Error: 'sendto' [%d-%s]", errno, errstr);
@@ -145,15 +145,15 @@ int32_t ocmw_send_clicmd_resp_to_occli(const char* buf, int32_t buflen)
* Input(s) : buflen
* Output(s) : buf
***************************************************************************/
int32_t ocmw_recv_clicmd_from_occli(char* buf, int32_t buflen)
int32_t ocmw_recv_clicmd_from_occli(char *buf, int32_t buflen)
{
char errstr[OCMW_SOCKET_ERROR_SIZE];
int32_t ret = 0;
int32_t destLen = sizeof(s_siClient);
/* Receive oc messages from other processes */
ret = recvfrom(s_ssockFd, buf, buflen, 0,
(struct sockaddr*) &s_siClient, (socklen_t*) &destLen);
ret = recvfrom(s_ssockFd, buf, buflen, 0, (struct sockaddr *)&s_siClient,
(socklen_t *)&destLen);
if (ret <= 0) {
strerror_r(errno, errstr, OCMW_SOCKET_ERROR_SIZE);
logerr("Error: 'recvfrom' [%d-%s]", errno, errstr);
@@ -168,7 +168,7 @@ int32_t ocmw_recv_clicmd_from_occli(char* buf, int32_t buflen)
* Input(s) : buf, buflen
* Output(s) :
***************************************************************************/
int32_t ocmw_send_alert_to_occli(const char* buf, int32_t buflen)
int32_t ocmw_send_alert_to_occli(const char *buf, int32_t buflen)
{
char errstr[OCMW_SOCKET_ERROR_SIZE];
int32_t ret = 0;
@@ -176,7 +176,7 @@ int32_t ocmw_send_alert_to_occli(const char* buf, int32_t buflen)
/* Send the message buffer over IPC */
ret = sendto(s_ssockfdAlert, buf, buflen, 0,
(const struct sockaddr *) &s_siServerAlert, destLen);
(const struct sockaddr *)&s_siServerAlert, destLen);
if (ret == -1) {
strerror_r(errno, errstr, OCMW_SOCKET_ERROR_SIZE);
logerr("Error: 'sendto' [%d-%s]", errno, errstr);

File diff suppressed because it is too large Load Diff

View File

@@ -40,7 +40,7 @@ extern uint8_t mcuMsgBuf[OCMP_MSG_SIZE];
* Input(s) : msgstr, msgsize
* Output(s) :
***************************************************************************/
void ocmw_ec_uart_msg_hndlr(const unsigned char* msgstr, int32_t msgsize)
void ocmw_ec_uart_msg_hndlr(const unsigned char *msgstr, int32_t msgsize)
{
/* Process the OC message received from EC */
if (msgsize > OCMP_MSG_SIZE) {
@@ -63,10 +63,10 @@ void ocmw_ec_uart_msg_hndlr(const unsigned char* msgstr, int32_t msgsize)
* Input(s) :
* Output(s) : args
***************************************************************************/
static void* ocmw_recv_uart_msg_service(void* args)
static void *ocmw_recv_uart_msg_service(void *args)
{
unsigned char msg[OCMP_MSG_SIZE] = {0};
unsigned char buf[OCMP_MSG_SIZE] = {0};
unsigned char msg[OCMP_MSG_SIZE] = { 0 };
unsigned char buf[OCMP_MSG_SIZE] = { 0 };
int32_t ret = 0;
const unsigned int msglen = OCMP_MSG_SIZE;
@@ -84,7 +84,7 @@ static void* ocmw_recv_uart_msg_service(void* args)
ret = read(s_fd, msg, msglen);
if (ret < 0) {
logerr("Error reading from %s (%d - %s)", ECTTY, errno,
strerror(errno));
strerror(errno));
continue;
}
if (memcmp(msg, buf, OCMP_MSG_SIZE) == 0) {
@@ -120,19 +120,19 @@ static void sa_handler_read(int32_t status)
***************************************************************************/
int32_t ocmw_init_ec_comm(handle_msg_from_ec_t msghndlr)
{
char pathName[100] = {0};
char pathName[100] = { 0 };
int32_t ret = 0;
struct termios newtio;
struct sigaction saio;
memset(pathName, 0, sizeof(pathName));
#ifdef INTERFACE_USB
#ifdef INTERFACE_USB
ret = ocmw_find_ttyacm_port(pathName);
if (ret != 0) {
return ret;
}
#else
memcpy(pathName, (char *) ECTTY, sizeof(ECTTY));
memcpy(pathName, (char *)ECTTY, sizeof(ECTTY));
#endif
/*
* Open the HSUART-1 port for communicating with EC
@@ -143,8 +143,7 @@ int32_t ocmw_init_ec_comm(handle_msg_from_ec_t msghndlr)
s_fd = open(pathName, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (s_fd == -1) {
if (s_fd == -1) {
logerr("Error opening %s (%d - %s)", ECTTY, errno,
strerror(errno));
logerr("Error opening %s (%d - %s)", ECTTY, errno, strerror(errno));
return -1;
}
}
@@ -168,14 +167,14 @@ int32_t ocmw_init_ec_comm(handle_msg_from_ec_t msghndlr)
cfsetospeed(&newtio, B115200);
newtio.c_cflag &= ~PARENB; /* No parity check */
newtio.c_cflag &= ~CSTOPB; /* 1 STOP bit */
newtio.c_cflag &= ~CSIZE; /* 8 DATA bits */
newtio.c_cflag &= ~CSIZE; /* 8 DATA bits */
newtio.c_cflag |= CS8;
newtio.c_cflag &= ~CRTSCTS; /* No HW flow control */
/* Enable always. CREAD - Enable receiver.
* CLOCAL - program doesn't own the tty. */
newtio.c_cflag |= (CLOCAL | CREAD);
newtio.c_cc[VTIME] = 10; /* Inter character TIME=t*0.1s, where t=10. */
newtio.c_cc[VMIN] = 0; //33; /* EC message frame size = 32 bytes */
newtio.c_cc[VMIN] = 0; // 33; /* EC message frame size = 32 bytes */
newtio.c_iflag &= ~(IXON | IXOFF | IXANY); /* No SW flow control */
newtio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
newtio.c_oflag &= ~OPOST;
@@ -183,8 +182,8 @@ int32_t ocmw_init_ec_comm(handle_msg_from_ec_t msghndlr)
tcsetattr(s_fd, TCSANOW, &newtio);
S_STOP_UART_RX_SERVICE = false;
ret = pthread_create(&s_uartrxthread, NULL, ocmw_recv_uart_msg_service,
NULL);
ret =
pthread_create(&s_uartrxthread, NULL, ocmw_recv_uart_msg_service, NULL);
if (ret != 0) {
logerr("pthread creation failed [%d-%s]", errno, strerror(errno));
} else {
@@ -223,18 +222,18 @@ int32_t ocmw_deinit_ec_comm(void)
* Input(s) : msgstr, msgsize
* Output(s) :
***************************************************************************/
int32_t ocmw_send_uart_msg_to_ec(const uint8_t* msgstr, int32_t msgsize)
int32_t ocmw_send_uart_msg_to_ec(const uint8_t *msgstr, int32_t msgsize)
{
uint8_t buf[OCMP_MSG_SIZE] = {0};
uint8_t buf[OCMP_MSG_SIZE] = { 0 };
int32_t ret = 0, bufWriteCount = 0;
int32_t sendPktNonpayloadSize = 0;
int32_t loopCount = 0;
OCMPMessageFrame *ecMsgFrame;
ecMsgFrame = (OCMPMessageFrame *) msgstr;
ecMsgFrame = (OCMPMessageFrame *)msgstr;
sendPktNonpayloadSize = (sizeof(OCMPMessage) - sizeof(void *)
+ sizeof(OCMPHeader));
sendPktNonpayloadSize =
(sizeof(OCMPMessage) - sizeof(void *) + sizeof(OCMPHeader));
if (msgstr == NULL) {
logerr("Error: Memory allocation problem");
@@ -250,7 +249,7 @@ int32_t ocmw_send_uart_msg_to_ec(const uint8_t* msgstr, int32_t msgsize)
memset(buf, 0, sizeof(buf));
memcpy(buf, msgstr, sendPktNonpayloadSize);
memcpy(&buf[sendPktNonpayloadSize], ((ecMsgFrame->message).info),
MAX_PARM_COUNT);
MAX_PARM_COUNT);
/* Write message frame to tty */
bufWriteCount = write(s_fd, buf, sizeof(buf));

853
firmware/host/ocwarestub/ocware_stub_database.c Executable file → Normal file

File diff suppressed because it is too large Load Diff

29
firmware/host/ocwarestub/ocware_stub_eth_comm.c Executable file → Normal file
View File

@@ -16,8 +16,8 @@ ocware_stub_ret ocware_stub_init_ethernet_comm(void)
int32_t inet_atom = 0;
/* Create socket */
s_stubSockFd = socket(OCMW_STUB_ETH_SOCK_DOMAIN,
OCMW_STUB_ETH_SOCK_TYPE, OCMW_STUB_ETH_SOCK_PROTOCOL);
s_stubSockFd = socket(OCMW_STUB_ETH_SOCK_DOMAIN, OCMW_STUB_ETH_SOCK_TYPE,
OCMW_STUB_ETH_SOCK_PROTOCOL);
if (s_stubSockFd < 0) {
printf("socket creation error [%d-%s]", errno, strerror(errno));
return STUB_FAILED;
@@ -28,8 +28,8 @@ ocware_stub_ret ocware_stub_init_ethernet_comm(void)
s_ocmwStubServer.sin_family = OCMW_STUB_ETH_SOCK_DOMAIN;
s_ocmwStubServer.sin_port = htons(OCMW_STUB_ETH_SOCK_SERVER_PORT);
s_ocmwStubServer.sin_addr.s_addr = inet_addr(OCMW_STUB_ETH_SOCK_SERVER_IP);
inet_atom = inet_aton(OCMW_STUB_ETH_SOCK_SERVER_IP,
&s_ocmwStubServer.sin_addr);
inet_atom =
inet_aton(OCMW_STUB_ETH_SOCK_SERVER_IP, &s_ocmwStubServer.sin_addr);
if (inet_atom == 0) {
printf("inet_aton failed");
return STUB_FAILED;
@@ -37,8 +37,8 @@ ocware_stub_ret ocware_stub_init_ethernet_comm(void)
memset(s_ocmwStubServer.sin_zero, '\0', sizeof(s_ocmwStubServer.sin_zero));
/*Bind socket with address struct*/
rc = bind(s_stubSockFd, (struct sockaddr *) &s_ocmwStubServer,
sizeof(s_ocmwStubServer));
rc = bind(s_stubSockFd, (struct sockaddr *)&s_ocmwStubServer,
sizeof(s_ocmwStubServer));
if (rc != 0) {
ocware_stub_deinit_ethernet_comm();
printf("Ehernet init failed \n");
@@ -72,7 +72,7 @@ ocware_stub_ret ocware_stub_deinit_ethernet_comm()
* STUB_FAILED - for failure
******************************************************************************/
ocware_stub_ret ocware_stub_send_msgframe_middleware(char **buffer,
int32_t bufferlen)
int32_t bufferlen)
{
int32_t rc = 0;
const int32_t errstr_len = OCWARE_STUB_ERR_STR_LEN;
@@ -87,8 +87,7 @@ ocware_stub_ret ocware_stub_send_msgframe_middleware(char **buffer,
memcpy(data, *buffer, sizeof(data));
rc = sendto(s_stubSockFd, data, OC_EC_MSG_SIZE, 0,
(struct sockaddr *) &s_ocmwStubServer,
dataLen);
(struct sockaddr *)&s_ocmwStubServer, dataLen);
if (rc < 0) {
strerror_r(errno, errstr, errstr_len);
printf("Error: 'send' [%d-%s]", errno, errstr);
@@ -108,8 +107,8 @@ ocware_stub_ret ocware_stub_send_msgframe_middleware(char **buffer,
* @return STUB_SUCCESS - for success
* STUB_FAILED - for failure
******************************************************************************/
ocware_stub_ret ocware_stub_recv_msgfrom_middleware(
char **buffer, int32_t bufferlen)
ocware_stub_ret ocware_stub_recv_msgfrom_middleware(char **buffer,
int32_t bufferlen)
{
int32_t rc = 0;
const int32_t errstr_len = OCWARE_STUB_ERR_STR_LEN;
@@ -120,10 +119,10 @@ ocware_stub_ret ocware_stub_recv_msgfrom_middleware(
if (buffer == NULL) {
return STUB_FAILED;
}
/* Receive the CLI command execution response string from OCMW over UDP socket */
rc = recvfrom(s_stubSockFd, data, OC_EC_MSG_SIZE,
0, (struct sockaddr *) &s_ocmwStubServer,
(socklen_t*)&dataLen);
/* Receive the CLI command execution response string from OCMW over UDP
* socket */
rc = recvfrom(s_stubSockFd, data, OC_EC_MSG_SIZE, 0,
(struct sockaddr *)&s_ocmwStubServer, (socklen_t *)&dataLen);
if (rc < 0) {
strerror_r(rc, errstr, errstr_len);
logerr("Error: 'recv' [%d-%s]", rc, errstr);

78
firmware/host/ocwarestub/ocware_stub_main_module.c Executable file → Normal file
View File

@@ -8,6 +8,7 @@
*/
#include <ocware_stub_main_module.h>
extern int16_t allAlertCount;
/******************************************************************************
* Function Name : ocware_stub_frame_newmsgframe
* Description : Frame the response packet from stub function
@@ -18,11 +19,12 @@
* @return STUB_SUCCESS - for success
* STUB_FAILED - for failure
******************************************************************************/
ocware_stub_ret ocware_stub_frame_newmsgframe(char *buffer, int32_t option)
ocware_stub_ret ocware_stub_frame_newmsgframe(char *buffer, int32_t option,
uint8_t *alertFlag)
{
int32_t ret = 0, index = 0;
OCMPMessageFrame *msgFrame = (OCMPMessageFrame *)buffer;
OCMPMessage *msgFrameData = (OCMPMessage*)&msgFrame->message;
OCMPMessage *msgFrameData = (OCMPMessage *)&msgFrame->message;
/* Frame the header packet for sending data to ec */
msgFrame->header.ocmpFrameLen = 0;
@@ -31,21 +33,19 @@ ocware_stub_ret ocware_stub_frame_newmsgframe(char *buffer, int32_t option)
msgFrame->header.ocmpSof = OCMP_MSG_SOF;
msgFrame->header.ocmpTimestamp = 0;
switch(msgFrameData->msgtype) {
switch (msgFrameData->msgtype) {
case OCMP_MSG_TYPE_COMMAND:
ret = ocware_stub_parse_command_message(buffer);
ret = ocware_stub_parse_command_message(buffer, alertFlag);
break;
case OCMP_MSG_TYPE_POST:
ret = ocware_stub_parse_post_get_message(buffer);
break;
default:
ret = ocware_stub_get_set_params(msgFrameData);
}
if (ret == STUB_SUCCESS) {
if (ret == STUB_SUCCESS && (msgFrameData->msgtype != OCMP_MSG_TYPE_ALERT)) {
/* Setting the action type as REPLY */
msgFrame->message.action = OCMP_AXN_TYPE_REPLY;
printf(" \n Sending Data :\n");
@@ -67,7 +67,7 @@ ocware_stub_ret ocware_stub_frame_newmsgframe(char *buffer, int32_t option)
* STUB_FAILED - for failure
******************************************************************************/
ocware_stub_ret ocware_stub_validate_msgframe_header(char *buf,
OCMPMessage *msgFrameData)
OCMPMessage *msgFrameData)
{
OCMPMessageFrame *MsgFrame = (OCMPMessageFrame *)buf;
OCMPHeader *header = (OCMPHeader *)&MsgFrame->header;
@@ -77,7 +77,7 @@ ocware_stub_ret ocware_stub_validate_msgframe_header(char *buf,
if (header->ocmpSof == OCMP_MSG_SOF) {
if (header->ocmpTimestamp == 0) {
memcpy(msgFrameData, &MsgFrame->message,
sizeof(OCMPMessage));
sizeof(OCMPMessage));
return STUB_SUCCESS;
}
}
@@ -97,27 +97,27 @@ ocware_stub_ret ocware_stub_validate_msgframe_header(char *buf,
******************************************************************************/
int32_t host_ocstubmain_func(int32_t argc, char *argv[])
{
int32_t rc = 0;
int32_t ret = 0;
char *buffer = NULL;
int32_t loopCount = 0;
char *rootpath = NULL;
uint8_t alertFlag = 0;
OCMPMessageFrame *msgFrame = NULL;
rc = ocware_stub_init_ethernet_comm();
if ( rc != STUB_SUCCESS) {
ret = ocware_stub_init_ethernet_comm();
if (ret != STUB_SUCCESS) {
printf("\n ERROR: Init Failed - %d", __LINE__);
ocware_stub_deinit_ethernet_comm();
return STUB_FAILED;
}
msgFrame = (OCMPMessageFrame *) malloc(sizeof(OCMPMessageFrame));
msgFrame = (OCMPMessageFrame *)malloc(sizeof(OCMPMessageFrame));
if (msgFrame == NULL) {
printf("\n ERROR: malloc");
ocware_stub_deinit_ethernet_comm();
return STUB_FAILED;
}
buffer = (char *) malloc(OC_EC_MSG_SIZE);
buffer = (char *)malloc(OC_EC_MSG_SIZE);
if (buffer == NULL) {
printf("\n ERROR: malloc");
ocware_stub_deinit_ethernet_comm();
@@ -136,41 +136,49 @@ int32_t host_ocstubmain_func(int32_t argc, char *argv[])
printf("\n\n OCWARE STUB APllication Started...\n");
while (1) {
memset(buffer, 0, sizeof(OCMPMessageFrame));
rc = ocware_stub_recv_msgfrom_middleware(&buffer,
sizeof(OCMPMessageFrame));
if (rc != STUB_SUCCESS) {
ret = ocware_stub_recv_msgfrom_middleware(&buffer,
sizeof(OCMPMessageFrame));
if (ret != STUB_SUCCESS) {
printf("ocware_stub_recv_msgfrom_middleware failed: error value :"
" %d\n", rc);
" %d\n",
ret);
return STUB_FAILED;
}
//#ifndef OCWARE_STUB_DEBUG
//#ifndef OCWARE_STUB_DEBUG
printf(" \n Received Data :\n");
for (loopCount = 0; loopCount < OC_EC_MSG_SIZE; loopCount++) {
printf("0x%x ", buffer[loopCount] & 0xff);
}
//#endif
rc = ocware_stub_validate_msgframe_header(buffer, &msgFrame->message);
if (rc != STUB_SUCCESS) {
printf("\n");
//#endif
ret = ocware_stub_validate_msgframe_header(buffer, &msgFrame->message);
if (ret != STUB_SUCCESS) {
printf("ocware_stub_validate_msgframe_header failed: error value :"
"%d\n", rc);
"%d\n",
ret);
return STUB_FAILED;
}
rc = ocware_stub_frame_newmsgframe(buffer, rc);
if (rc != STUB_SUCCESS) {
ret = ocware_stub_frame_newmsgframe(buffer, ret, &alertFlag);
if (ret != STUB_SUCCESS) {
printf("ocware_stub_frame_newmsgframe failed: error value :"
"%d\n", rc);
"%d\n",
ret);
return STUB_FAILED;
}
rc = ocware_stub_send_msgframe_middleware(&buffer,
sizeof(OCMPMessageFrame));
if (rc != STUB_SUCCESS) {
printf("ocware_stub_send_msgframe_middleware failed: error value :"
"%d\n", rc);
return STUB_FAILED;
if (alertFlag > 0) {
ret = ocware_stub_frame_alert_msgframe(buffer);
} else {
ret = ocware_stub_send_msgframe_middleware(
&buffer, sizeof(OCMPMessageFrame));
if (ret != STUB_SUCCESS) {
printf(
"ocware_stub_send_msgframe_middleware failed: error value :"
"%d\n",
ret);
return STUB_FAILED;
}
}
}
free(msgFrame);

79
firmware/host/ocwarestub/ocware_stub_parse_message.c Executable file → Normal file
View File

@@ -11,6 +11,7 @@
#include <ocmw_occli_comm.h>
#include <ocware_stub_main_module.h>
extern const Component sys_schema[];
/******************************************************************************
* Function Name : ocware_stub_parse_debug_actiontype
* Description : Convert debug actiontype into the SET/GET
@@ -25,9 +26,7 @@ ocware_stub_ret ocware_stub_parse_debug_actiontype(OCMPMessage *msgFrameData)
{
ocware_stub_ret ret = STUB_SUCCESS;
if ((debugSetCommand != STUB_FAILED) ||
(debugGetCommand != STUB_FAILED)) {
if ((debugSetCommand != STUB_FAILED) || (debugGetCommand != STUB_FAILED)) {
if ((msgFrameData->action) == debugGetCommand) {
msgFrameData->action = OCMP_AXN_TYPE_GET;
} else if ((msgFrameData->action) == debugSetCommand) {
@@ -41,6 +40,46 @@ ocware_stub_ret ocware_stub_parse_debug_actiontype(OCMPMessage *msgFrameData)
return ret;
}
/******************************************************************************
* Function Name : ocware_stub_parse_command_from_schema
* Description : Parse the command from schema
*
* @param msgFrameData - output pointer to the OCMPheader field of the message
* from MW (by reference)
*
* @return tempAlertFlag
*******************************************************************************/
uint8_t ocware_stub_parse_command_from_schema(OCMPMessage *msgFrameData)
{
const Component *component = NULL;
const Component *subSystem = NULL;
const Command *command = NULL;
uint8_t subsystemNbr = 0;
uint8_t commandNbr = 0;
uint8_t coponentNbr = 1;
uint8_t tempAlertFlag = 0;
for (subSystem = sys_schema; subSystem && subSystem->name; subSystem++) {
if (subsystemNbr == msgFrameData->subsystem) {
component = subSystem->components;
if (coponentNbr == msgFrameData->componentID) {
command = component->commands;
while (command && command->name) {
if ((strcmp(command->name, "getAlertLogs") == 0) &&
(commandNbr == msgFrameData->action)) {
tempAlertFlag++;
break;
}
commandNbr++;
command++;
}
break;
}
}
subsystemNbr++;
}
return tempAlertFlag;
}
/******************************************************************************
* Function Name : ocware_stub_handle_post_enable
* Description : Process the post enable message
@@ -87,7 +126,6 @@ ocware_stub_ret ocware_stub_get_set_params(OCMPMessage *msgFrameData)
ret = STUB_FAILED;
}
return ret;
}
/******************************************************************************
* Function Name : ocware_stub_parse_post_get_message
@@ -106,19 +144,46 @@ ocware_stub_ret ocware_stub_parse_post_get_message(char *buffer)
uint16_t paramId;
char *payload = NULL;
if(buffer == NULL) {
if (buffer == NULL) {
return ret;
}
msgFrame = (OCMPMessageFrame *)buffer;
msgFrameData = (OCMPMessage*)&msgFrame->message;
msgFrameData = (OCMPMessage *)&msgFrame->message;
payload = (char *)&msgFrameData->info;
msgFrameData->action = OCMP_AXN_TYPE_REPLY;
paramId = msgFrameData->parameters;
if(paramId == PostResult) {
if (paramId == PostResult) {
ret = ocware_stub_get_post_database(msgFrameData, payload);
} else if (paramId == PostEnable) {
ret = ocware_stub_handle_post_enable(msgFrameData);
}
return ret;
}
/******************************************************************************
* Function Name : ocware_stub_parse_alert_get_message
* Description : Parse alert messages from MW
*
* @param buffer - output pointer to the message from MW
* index - index for record
*
* @return STUB_SUCCESS - for success
* STUB_FAILED - for failure
******************************************************************************/
ocware_stub_ret ocware_stub_parse_alert_get_message(char *buffer, int8_t index)
{
ocware_stub_ret ret = STUB_FAILED;
OCMPMessageFrame *msgFrame = NULL;
OCMPMessage *msgFrameData = NULL;
char *payload = NULL;
if (buffer == NULL) {
return ret;
}
msgFrame = (OCMPMessageFrame *)buffer;
msgFrameData = (OCMPMessage *)&msgFrame->message;
payload = (char *)&msgFrameData->info;
msgFrameData->action = OCMP_MSG_TYPE_ALERT;
ret = ocware_stub_get_alert_database(msgFrameData, payload, index);
return ret;
}

View File

@@ -11,8 +11,8 @@
#include <ocwdg_daemon.h>
#include <logger.h>
#define OCWDG_NUMBER_ZERO 0
#define OCWDG_NUMBER_ONE 1
#define OCWDG_NUMBER_ZERO 0
#define OCWDG_NUMBER_ONE 1
extern int32_t ocmw_sem_wait_nointr(sem_t *sem);
@@ -37,7 +37,7 @@ int32_t ocwdg_init(void)
* the msg coming from UART ec to ap
*/
ret = pthread_create(&ocWdgThreadid, NULL, ocwdg_thread_comm_with_ec,
NULL);
NULL);
if (ret != OCWDG_NUMBER_ZERO) {
return ret;
}
@@ -52,7 +52,7 @@ int32_t ocwdg_init(void)
* Input(s) : pthreadData
* Output(s) :
******************************************************************************/
void * ocwdg_thread_comm_with_ec(void *pthreadData)
void *ocwdg_thread_comm_with_ec(void *pthreadData)
{
OCMPMessageFrame ecMsgFrame;
OCMPHeader ecMsgHeader;
@@ -90,8 +90,8 @@ void * ocwdg_thread_comm_with_ec(void *pthreadData)
ecMsgFrame.message = ecCoreMsg;
/* Populate the Core packet payload */
ecMsgFrame.message.info = (int8_t *) malloc(
sizeof(char) * MAX_PARM_COUNT);
ecMsgFrame.message.info =
(int8_t *)malloc(sizeof(char) * MAX_PARM_COUNT);
if (ecMsgFrame.message.info == NULL) {
printf("\n Memory allocation failed \n");
}
@@ -100,15 +100,15 @@ void * ocwdg_thread_comm_with_ec(void *pthreadData)
#ifdef INTERFACE_ETHERNET
/* Send the packetize data to ec through ethernet*/
ret = ocmw_send_eth_msgto_ec((int8_t *)&ecMsgFrame, (int32_t)32,
OCMW_EC_DEV);
OCMW_EC_DEV);
if (ret != OCWDG_NUMBER_ZERO) {
logerr ("ocmw_send_eth_msgto_ec() failed");
logerr("ocmw_send_eth_msgto_ec() failed");
}
#else
/* Send the packetize data to ec through uart*/
ret = ocmw_send_uart_msg_to_ec((uint8_t *) &ecMsgFrame,
sizeof(ecMsgFrame));
ret = ocmw_send_uart_msg_to_ec((uint8_t *)&ecMsgFrame,
sizeof(ecMsgFrame));
if (ret != OCWDG_NUMBER_ZERO) {
logerr("ocmw_send_uart_msg_to_ec() failed");
}

View File

@@ -17,7 +17,7 @@
* Input(s) : ident
* Output(s) :
***************************************************************************/
void initlog(const char* ident)
void initlog(const char *ident)
{
openlog(ident, LOG_CONS | LOG_PID, LOG_USER);
}

View File

@@ -11,17 +11,17 @@
#include <stdio.h>
#include <util.h>
#define UTIL_NUMBER_ZERO 0
#define UTIL_NUMBER_ZERO 0
void hexdisp(const unsigned char* buf, int buflen)
void hexdisp(const unsigned char *buf, int buflen)
{
int c=UTIL_NUMBER_ZERO, i=UTIL_NUMBER_ZERO;
for (c=UTIL_NUMBER_ZERO; c<buflen; c++) {
int c = UTIL_NUMBER_ZERO, i = UTIL_NUMBER_ZERO;
for (c = UTIL_NUMBER_ZERO; c < buflen; c++) {
printf("0x%02x ", buf[c]);
if ((c+1)%8 == UTIL_NUMBER_ZERO) {
if ((c + 1) % 8 == UTIL_NUMBER_ZERO) {
printf("\t");
for(i=(c+1)-8; i<=(c+1); i++)
printf("%c", (buf[i]>0x20 && buf[i]<0x7F) ? buf[i] : '.');
for (i = (c + 1) - 8; i <= (c + 1); i++)
printf("%c", (buf[i] > 0x20 && buf[i] < 0x7F) ? buf[i] : '.');
printf("\n");
}
}