// // Function: Rcv_ProcessResponceSDU // // Description: Process Responce Message Data // // Arguments: // // Name Type Direction Description // ----------- ----------- ----------- ----------------------------------- // NewDataBlock DataRecord * OUT Block of data ( For return status ) // Buff t_uchar * IN Buffer with data to process // Len int IN Length of buffer // // Return Values: // // Name Explanation // ----------- --------------------------------------------------------------- // RetStatus Responce type ( error code ) // int Rcv_ProcessResponceSDU( DataRecord *pModemStatus, t_uchar *Buff, int Len ) { int RetStatus = RM_SUCCESS; QueueNodeDef *pNode = NULL; int InternalID = Buff[LEFT_SDU_TAG]; //Left Byte of ID //Buff is only data block - without [SOH], [INTEGRITY] and [EOT] InternalID = (InternalID<<8) + Buff[RIGHT_SDU_TAG]; if ( (pNode = QueueFindNode( SEND_QUEUE, InternalID )) == NULL ) { //Create node for command that is NOT in my SEND_QUEUE pNode = QueueInsert( SEND_QUEUE, NULL ); //Will be freed in QueueDeleteNode(); pNode->Message.DataBuffer = (t_uchar *)Mem_Allocate( RM_MINI_BLOCK_SIZE ); pNode->Message.DataBuffer[OPERATOR] = 0xFF; //TYPE UNKNOWN }//end if //Main function to process responce RetStatus = Resp_DisplayFormatted( pNode, Buff, Len ); QueueDeleteNode( SEND_QUEUE, pNode ); pModemStatus->extendedStatus = RM_RESPONCE; return( RetStatus ); //Responce Result }//Rcv_ProcessResponceSDU
static int InterpreteR_RADIO_IN_RANGE( t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif switch ( *Buff ) { case '1': sprintf( TempBuf, "%s Radio in range = O.K. \n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; case '2': sprintf( TempBuf, "%s Radio out of range\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; default: sprintf( TempBuf, "%s Radio in range = RESERVED \n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; }//end switch #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end InterpreteR_RADIO_IN_RANGE
static int InterpreteR_RCV_MODE( t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif switch ( *Buff ) { case UNCONFIRMED: sprintf( TempBuf, "%s Receive mode = UNCONFIRMED \n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; case CONFIRMED: sprintf( TempBuf, "%s Receive mode = CONFIRMED \n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; default: sprintf( TempBuf, "%s Receive mode = BAD DATA \n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; }//end switch #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end InterpreteR_RCV_MODE
static int InterpreteR_TX_STATUS( t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; State TransmitterState = *Buff; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif switch ( TransmitterState ) { case DISABLE: sprintf( TempBuf, "%s Transmitter = DISABLED \n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; case ENABLE: sprintf( TempBuf, "%s Transmitter = ENABLED \n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; default: sprintf( TempBuf, "%s Transmitter = BAD DATA \n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; }//end switch #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end InterpreteR_TX_STATUS
CfrTil * _CfrTil_New ( CfrTil * cfrTil ) { // nb. not all of this logic has really been needed or used or tested; it should be reworked according to need Namespace * nss = 0 ; if ( cfrTil ) { if ( _Q_->RestartCondition < RESTART ) { nss = cfrTil->Namespaces ; // in this case (see also below) only preserve Namespaces, all else is recycled and reinitialized if ( cfrTil->LogFILE ) { CfrTil_LogOff ( ) ; } } CfrTil_ResetMemory ( ) ; } else { nss = 0 ; } cfrTil = ( CfrTil* ) Mem_Allocate ( sizeof ( CfrTil ), OPENVMTIL ) ; _CfrTil_Init ( cfrTil, nss ) ; Linux_SetupSignals ( &cfrTil->JmpBuf0, 1 ) ; return cfrTil ; }
static int InterpreteR_CONFIG_BLOCK( t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif ConfigurationBlock *ConfBlk = (ConfigurationBlock *)Buff; int ConfBlkSize = sizeof(ConfigurationBlock); if ( Len >= ConfBlkSize ) { InterpreteR_PROD_ID ( ConfBlk->R_PROD_ID, 4, MessageBuf ); sprintf( TempBuf, "%s ", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability InterpreteR_SW_VERSION ( ConfBlk->R_SW_VERSION, 3, MessageBuf ); sprintf( TempBuf, "%s ", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability InterpreteR_RPM_ID ( ConfBlk->R_RPM_ID, 4, MessageBuf ); sprintf( TempBuf, "%s ", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability InterpreteR_RPM_VID ( ConfBlk->R_RPM_VID, 2, MessageBuf ); sprintf( TempBuf, "%s ", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability InterpreteR_MAX_DATA_SIZE ( ConfBlk->R_MAX_DATA_SIZE, 2, MessageBuf ); }; #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end InterpreteR_CONFIG_BLOCK
byte * _CfrTil_NamelessObjectNew ( int32 size ) { byte * obj = 0 ; if ( size ) { obj = Mem_Allocate ( size, OBJECT_MEMORY ) ; } return obj ; }
static int InterpreteR_EVENT_STATUS( t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; t_uchar EventStatus = *Buff; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif //Figure 5-22 sprintf( TempBuf, "%s Event status:", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability if ( EventStatus & 0x01 ) { sprintf( TempBuf, "%s HW_EVENT", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability }//end if if ( EventStatus & 0x02 ) { sprintf( TempBuf, "%s RX_EVENT", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability }//end if if ( EventStatus & 0x04 ) { sprintf( TempBuf, "%s TX_EVENT", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability }//end if if ( EventStatus & 0x08 ) { sprintf( TempBuf, "%s RCV_MSG_NOTIFICATION", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability }//end if if ( EventStatus & 0x10 ) { sprintf( TempBuf, "%s RCV_MSG_DATA", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability }//end if if ( EventStatus & 0x20 ) { sprintf( TempBuf, "%s CONTROL", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability }//end if sprintf( TempBuf, "%s\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end InterpreteR_EVENT_STATUS
// // Function: Rcv_ProcessInQueue // // Description: Get Data from UART and compose Data for RM_Receive function // // Arguments: // // Name Type Direction Description // ----------- ----------- ----------- ----------------------------------- // dataR DataRecord * OUT Data buffer // // Return Values: // // Name Explanation // ----------- ---------------------------------------------------------------- // RetStatus Error code // int Rcv_ProcessInQueue( DataRecord *dataR ) { int RetStatus = RM_SUCCESS; #ifdef RM_HEAP UartMsgDef *pMessageBuf = (UartMsgDef *)Mem_Allocate( sizeof( UartMsgDef ) ); #else UartMsgDef MessageBuf; UartMsgDef *pMessageBuf = &MessageBuf; #endif QueueNodeDef *pHead = QueueGetHead(RECV_QUEUE); HeapBuffDef *UnProcessedData = Data_GetHeapPtr(); //Get data from UART pMessageBuf->DataBuffer = (t_uchar *)Mem_Allocate( MAX_LENGTH_MSG+16 ); RetStatus = Rcv_GetUartBuffer( pMessageBuf ); if ( pMessageBuf->DataLength > 0 ) // if ( RetStatus > 0 ) { //Print not processed data //PrintBuffer( "[I] Uart_GetBuf:", pMessageBuf->DataBuffer, pMessageBuf->DataLength ); Data_AddToHeap( UnProcessedData, pMessageBuf ); //All work will be done here RetStatus = Rcv_ProcessHeap( UnProcessedData, dataR ); }//end if else if ( pMessageBuf->DataLength < 0 ) RetStatus = pMessageBuf->DataLength; if ( pHead->Message.messagesInQueue > 0 ) PrintLogMessage( "[I] QUEUE LENGTH:", "", pHead->Message.messagesInQueue ); Mem__Free( pMessageBuf->DataBuffer ); #ifdef RM_HEAP Mem__Free( pMessageBuf ); #endif return( RetStatus ); }//end Rcv_ProcessInQueue
Property * _Property_Create ( ) { Property * property ; #if 0 if ( category & ( LOCAL_VARIABLE | PARAMETER_VARIABLE ) ) { property = ( Property* ) Mem_Allocate_AddToList ( sizeof (Property ), SESSION, 0 ) ; } else #endif { property = ( Property * ) Mem_Allocate ( sizeof (Property ), DICTIONARY ) ; } return property ; }
// // Function: Resp_CheckCommandType // // Description: Print to MessageBuf command type // // Arguments: // // Name Type Direction Description // ----------- ----------- ----------- ----------------------------------- // pNode QueueNodeDef* IN Node in QUEUE ( For check for what command this responce ) // Buff t_uchar* IN Buffer with data to process // Len int IN Length of buffer // MessageBuf char* OUT Buffer to return formatted string // // Return Values: // // Name Explanation // ----------- --------------------------------------------------------------- // RetStatus Error code // static int Resp_CheckCommandType( QueueNodeDef *pNode, t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; CommandOperator CommandType = pNode->Message.DataBuffer[OPERATOR]; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif switch( CommandType ) { case SEND: sprintf( TempBuf, "%s RESP to Command SENT\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; case READ_MSG: sprintf( TempBuf, "%s RESP to Command READ_MSG\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; case CTL_EVENT: sprintf( TempBuf, "%s RESP to Command CTL_EVENT\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; case GET_STATUS: Resp_ProcessGetStatus( pNode, Buff, Len, MessageBuf ); break; case SET_CNF: sprintf( TempBuf, "%s RESP to Command SET_CNF\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; case RESET_RPM: sprintf( TempBuf, "%s RESP to Command RESET_RPM\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; default: sprintf( TempBuf, "%s RESP to Command UNKNOWN\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; }//end switch #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end Resp_CheckCommandType
// // Function: Resp_ProcessSyntaxSDU // // Description: Process Responce Message Data with SYNTAX status // // Arguments: // // Name Type Direction Description // ----------- ----------- ----------- ----------------------------------- // pNode QueueNodeDef * IN Node in QUEUE ( For check for what command this responce ) // Buff t_uchar * IN Buffer with data to process // Len int IN Length of buffer // MessageBuf char * OUT Buffer to return formatted string // // Return Values: // // Name Explanation // ----------- --------------------------------------------------------------- // RetStatus Error code // static int Resp_ProcessSyntaxSDU( QueueNodeDef *pNode, t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; SyntaxErrorCode SyntaxType = Buff[EXT_RESULT_CODE]; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif QueueNodeDef *pHead = QueueGetHead(SEND_QUEUE); VRM_StateDef *Statistics = (VRM_StateDef *)(pHead->Message.DataBuffer); if ( pNode->Message.DataBuffer != NULL ) PrintBuffer( "[E] Syntax error in command:", pNode->Message.DataBuffer, pNode->Message.DataLength ); RetStatus = Resp_CheckCommandType( pNode, Buff, Len, MessageBuf ); switch( SyntaxType ) { case INVALID: //ASCII 'b' //Invalid option in command Statistics->SYNTAX_CODE.INVALID++; Statistics->LAST_UPDATED_FIELD = POS_INVALID; sprintf( TempBuf, "%s Invalid option in command\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; case TOO_LONG: //ASCII 'c' //Data too long Statistics->SYNTAX_CODE.TOO_LONG++; Statistics->LAST_UPDATED_FIELD = POS_TOO_LONG; sprintf( TempBuf, "%s Data too long\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; default: Statistics->SYNTAX_CODE.UNDEFINED++; Statistics->LAST_UPDATED_FIELD = POS_UNDEFINED_SYNTAX_CODE; sprintf( TempBuf, "%s UNKNOWN = %04X HEX\n", MessageBuf, SyntaxType ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; }//end switch #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); //Responce SDU }//end Resp_ProcessSyntaxSDU
static int InterpreteR_CHAN_TABLE( t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif sprintf( TempBuf, "%s R_CHAN_TABLE\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end InterpreteR_CHAN_TABLE
static int InterpreteR_STATUS_BLOCK( t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif StatusBlock *StatBlk = (StatusBlock *)Buff; if ( sizeof(StatusBlock) <= Len ) { InterpreteR_RCV_MODE ( &StatBlk->R_RX_STATUS, 1, MessageBuf ); sprintf( TempBuf, "%s ", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability InterpreteR_RX_STATUS ( &StatBlk->R_TX_STATUS, 1, MessageBuf ); sprintf( TempBuf, "%s ", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability InterpreteR_ANTENNA ( &StatBlk->R_ANTENNA, 1, MessageBuf ); sprintf( TempBuf, "%s ", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability InterpreteR_RADIO_IN_RANGE ( &StatBlk->R_RADIO_IN_RANGE, 1, MessageBuf ); sprintf( TempBuf, "%s ", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability InterpreteR_OB_MSG_COUNT ( StatBlk->R_OB_COUNT, 2, MessageBuf ); sprintf( TempBuf, "%s ", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability InterpreteR_IB_MSG_COUNT ( StatBlk->R_IB_COUNT, 2, MessageBuf ); sprintf( TempBuf, "%s ", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability InterpreteR_FLOW_CONTROL ( &StatBlk->R_FLOW_CONTROL, 1, MessageBuf ); sprintf( TempBuf, "%s ", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability InterpreteR_EVENT_STATUS ( &StatBlk->R_EVENT_STATUS, 1, MessageBuf ); sprintf( TempBuf, "%s ", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability InterpreteR_RADIO_CHANNEL ( StatBlk->R_RADIO_CHANNEL, 2, MessageBuf ); }//end if #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end InterpreteR_STATUS_BLOCK
static int InterpreteR_IB_MSG_COUNT( t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; int IB_count = 0; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif memcpy( &IB_count, Buff, 2 ); sprintf( TempBuf, "%s Inbound SDUs = %04X HEX\n", MessageBuf, IB_count ); strcpy( MessageBuf, TempBuf );//for DOS compatability #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end InterpreteR_IB_MSG_COUNT
static int InterpreteR_PROD_ID( t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; long ProductID = 0; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif memcpy( &ProductID, Buff, Len ); sprintf( TempBuf, "%s Product id = %08X HEX\n", MessageBuf, ProductID ); strcpy( MessageBuf, TempBuf );//for DOS compatability #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end InterpreteR_PROD_ID
static int InterpreteR_FLOW_CONTROL( t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; FlowControl FlowState = *Buff; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif switch ( FlowState ) { case NONE: sprintf( TempBuf, "%s Flow control = NONE \n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; case XON_XOFF: sprintf( TempBuf, "%s Flow control = XON_XOFF \n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; case RTS_CTS: sprintf( TempBuf, "%s Flow control = RTS_CTS \n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; default: sprintf( TempBuf, "%s Flow control = BAD DATA \n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; }//end switch #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end InterpreteR_FLOW_CONTROL
static int InterpreteR_SW_VERSION( t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; int HW_Platform = Buff[0]; int RF_Protocol = Buff[1]; int ReleaseLevel= Buff[2]; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif sprintf( TempBuf, "%s Hardware Platform = %02X HEX\n" " RF protocol = %02X HEX\n" " Release level = %02X HEX\n", MessageBuf, HW_Platform, RF_Protocol, ReleaseLevel ); strcpy( MessageBuf, TempBuf );//for DOS compatability #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end InterpreteR_SW_VERSION
static int InterpreteR_RADIO_CHANNEL( t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; int RadioChannel= 0; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif //Figure 5-16 memcpy( &RadioChannel, Buff, 2 ); RadioChannel &= 0x0FFF; sprintf( TempBuf, "%s Radio channel = %04X HEX\n", MessageBuf, RadioChannel ); strcpy( MessageBuf, TempBuf );//for DOS compatability #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end InterpreteR_RADIO_CHANNEL
static int InterpreteR_MAX_DATA_SIZE( t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; long max_data_size = 0; const int SizeMax_data_size = 2; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif if ( Len >= SizeMax_data_size ) { memcpy( &max_data_size, Buff, SizeMax_data_size ); sprintf( TempBuf, "%s Max data size = %05d DEC\n", MessageBuf, max_data_size ); strcpy( MessageBuf, TempBuf );//for DOS compatability }//end R_MAX_DATA_SIZE #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end InterpreteR_MAX_DATA_SIZE
static int InterpreteR_RPM_VID( t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; int ProductVID = 0; const int SizeProductVID = 2; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif if ( Len >= SizeProductVID ) { memcpy( &ProductVID, Buff, Len ); sprintf( TempBuf, "%s Rpm_VID = %04X HEX\n", MessageBuf, ProductVID ); strcpy( MessageBuf, TempBuf );//for DOS compatability }//end R_RPM_VID #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); }//end InterpreteR_RPM_VID
// // Function: Resp_ProcessGetStatus // // Description: Process Responce Message Data with responce to status request // // Arguments: // // Name Type Direction Description // ----------- ----------- ----------- ----------------------------------- // pNode QueueNodeDef * IN Node in QUEUE ( For check for what command this responce ) // Buff t_uchar * IN Buffer with data to process // Len int IN Length of buffer // MessageBuf char * OUT Buffer to return formatted string // // Return Values: // // Name Explanation // ----------- --------------------------------------------------------------- // RetStatus Error code // static int Resp_ProcessGetStatus( QueueNodeDef *pNode, t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; int DataOffset = EXT_RESULT_CODE; t_uchar *pData = Buff + DataOffset; int DataLength = Len - DataOffset; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif StatusRequestType StatusType = pNode->Message.DataBuffer[STATUS_REQUEST]; switch( StatusType ) { case R_CONFIG_BLOCK: InterpreteR_CONFIG_BLOCK ( pData, DataLength, MessageBuf ); break; case R_STATUS_BLOCK: InterpreteR_STATUS_BLOCK ( pData, DataLength, MessageBuf ); break; case R_PROD_ID: InterpreteR_PROD_ID ( pData, DataLength, MessageBuf ); break; case R_SW_VERSION: InterpreteR_SW_VERSION ( pData, DataLength, MessageBuf ); break; case R_RPM_ID: InterpreteR_RPM_ID ( pData, DataLength, MessageBuf ); break; case R_RPM_VID: InterpreteR_RPM_VID ( pData, DataLength, MessageBuf ); break; case R_MAX_DATA_SIZE: InterpreteR_MAX_DATA_SIZE ( pData, DataLength, MessageBuf ); break; case R_RCV_MODE: InterpreteR_RCV_MODE ( pData, DataLength, MessageBuf ); break; case R_RX_STATUS: InterpreteR_RX_STATUS ( pData, DataLength, MessageBuf ); break; case R_TX_STATUS: InterpreteR_TX_STATUS ( pData, DataLength, MessageBuf ); break; case R_ANTENNA: InterpreteR_ANTENNA ( pData, DataLength, MessageBuf ); break; case R_RADIO_IN_RANGE: InterpreteR_RADIO_IN_RANGE ( pData, DataLength, MessageBuf ); break; case R_OB_MSG_COUNT: InterpreteR_OB_MSG_COUNT ( pData, DataLength, MessageBuf ); break; case R_IB_MSG_COUNT: InterpreteR_IB_MSG_COUNT ( pData, DataLength, MessageBuf ); break; case R_FLOW_CONTROL: InterpreteR_FLOW_CONTROL ( pData, DataLength, MessageBuf ); break; case R_EVENT_STATUS: InterpreteR_EVENT_STATUS ( pData, DataLength, MessageBuf ); break; case R_RADIO_CHANNEL: InterpreteR_RADIO_CHANNEL ( pData, DataLength, MessageBuf ); break; case R_CHAN_TABLE: InterpreteR_CHAN_TABLE ( pData, DataLength, MessageBuf ); break; default: sprintf( TempBuf, "%s UNKNOWN = %02X HEX", MessageBuf, StatusType ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; }//end switch #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); //Responce SDU }//end Resp_ProcessGetStatus
zFunctionResult DS_CreateDataset(void) { zInt i,j; zInt flag; DatasetStruct * newDataset; j = 0; flag = 0; if (DS_datasetVault != NULL) { //some nets exist, check them //are there dead nets among them? for (i = 0; i < DS_datasetVaultMaxDatasetsAllocated; i++) { if ((*DS_datasetVault[i]).datasetIsDead == DS_DATASET_IS_DEAD) { //ok, found dead net //reinitialize it flag = 1; j = i; break; } } } if (flag == 0) { //no dead datasets //so allocating new one //step 1. alloc mem for new net newDataset = (DatasetStruct *) Mem_Allocate(sizeof(DatasetStruct)); if (newDataset == NULL) { //oops, realloc failed return ZERROR_MEMORY_ALLOCATION_ERROR; } //step 2. realloc NetVault DS_datasetVault = (DatasetStruct **) Mem_Reallocate(DS_datasetVault, (DS_datasetVaultMaxDatasetsAllocated + 1) * sizeof(DatasetStruct *)); if (DS_datasetVault == NULL) { //oops, realloc failed return ZERROR_MEMORY_ALLOCATION_ERROR; } DS_datasetVault[DS_datasetVaultMaxDatasetsAllocated] = newDataset; j = DS_datasetVaultMaxDatasetsAllocated; DS_datasetVaultMaxDatasetsAllocated++; } //initialize net //j points to net (*DS_datasetVault[j]).datasetIsAcquired = DS_DATASET_IS_NOT_ACQUIRED; (*DS_datasetVault[j]).datasetIsDead = DS_DATASET_IS_NOT_DEAD; Mx_CreateMatrix(&((*DS_datasetVault[j]).data), 0, 0); Mx_CreateMatrix(&((*DS_datasetVault[j]).dataOut), 0, 0); return j; }
// // Function: Resp_DisplayFormatted // // Description: Process Responce Message Data // // Arguments: // // Name Type Direction Description // ----------- ----------- ----------- ----------------------------------- // pNode QueueNodeDef * IN Node in QUEUE ( For check for what command this responce ) // Buff t_uchar * IN Buffer with data to process // Len int IN Length of buffer // // Return Values: // // Name Explanation // ----------- --------------------------------------------------------------- // RetStatus Error code // int Resp_DisplayFormatted( QueueNodeDef *pNode, t_uchar *Buff, int Len ) { int RetStatus = RM_SUCCESS; time_t ltime = 0; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); char *MessageBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; char TimeBuf[MAX_LENGTH_STR]; char MessageBuf[MAX_LENGTH_STR]; #endif QueueNodeDef *pHead = QueueGetHead(SEND_QUEUE); VRM_StateDef *Statistics = (VRM_StateDef *)(pHead->Message.DataBuffer); RetStatus = Buff[RESULT_CODE]; MessageBuf[0] = '\0'; sprintf( MessageBuf, "Length = %04X HEX, SDU Tag = %04X HEX, Result Code =", Len - RESPONCE_DATA_OVERHEAD, pNode->InternalID ); //Get current time string _strtime( TimeBuf ); switch( RetStatus ) { case SUCCESS: //SUCCESS == '1' Statistics->RESP.SUCCESS++; Statistics->LAST_UPDATED_FIELD = POS_SUCCESS; sprintf( TempBuf, "%s SUCCESS\n Details:", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability sprintf( TempBuf, "[S] Response: SUCCESS, SENT: %ld, RESP: %ld, DIFF: %ld, TIME: %s", pNode->TimeStamp, time( <ime ), time( <ime ) - pNode->TimeStamp, TimeBuf ); Resp_ProcessSuccessSDU( pNode, Buff, Len, MessageBuf ); RetStatus = RM_SUCCESS; break; case XFAIL: //XFAIL == '2' Statistics->RESP.XFAIL++; Statistics->LAST_UPDATED_FIELD = POS_XFAIL; sprintf( TempBuf, "%s XFAIL \n Details:", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability sprintf( TempBuf, "[E] Response: XFAIL, SENT: %ld, RESP: %ld, TIME: %s", pNode->TimeStamp, time( <ime ), TimeBuf ); Resp_ProcessXfailSDU( pNode, Buff, Len, MessageBuf ); RetStatus = RM_ERROR_GENERAL; break; case SYNTAX: //SYNTAX == '3' Statistics->RESP.SYNTAX++; Statistics->LAST_UPDATED_FIELD = POS_SYNTAX; sprintf( TempBuf, "%s SYNTAX \n Details:", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability sprintf( TempBuf, "[E] Response: SYNTAX ERROR, SENT: %ld, RESP: %ld, TIME: %s", pNode->TimeStamp, time( <ime ), TimeBuf ); Resp_ProcessSyntaxSDU( pNode, Buff, Len, MessageBuf ); RetStatus = RM_ERROR_GENERAL; break; default: Statistics->RESP.UNDEFINED++; Statistics->LAST_UPDATED_FIELD = POS_UNDEFINED_RESP; sprintf( TempBuf, "%s UNKNOWN = %04X HEX\n", MessageBuf, RetStatus ); strcpy( MessageBuf, TempBuf );//for DOS compatability strcpy( TempBuf, "[E] Response: UNKNOWN" ); break; }//end switch //Print all messages formatted in MessageBuf PrintLogMessage( TempBuf, "", 0 ); PrintBuffer( "[RESP][Length][SDU Tag][Result Code][Responce Information]", Buff, Len ); PrintLogMessage( MessageBuf, "", 0 ); #ifdef RM_HEAP Mem__Free( MessageBuf ); Mem__Free( TempBuf ); #endif return( RetStatus ); //Responce SDU }//end Resp_DisplayFormatted
// // Function: Resp_ProcessXfailSDU // // Description: Process Responce Message Data with XFAIL status // // Arguments: // // Name Type Direction Description // ----------- ----------- ----------- ----------------------------------- // pNode QueueNodeDef * IN Node in QUEUE ( For check for what command this responce ) // Buff t_uchar * IN Buffer with data to process // Len int IN Length of buffer // MessageBuf char * OUT Buffer to return formatted string // // Return Values: // // Name Explanation // ----------- --------------------------------------------------------------- // RetStatus Error code // static int Resp_ProcessXfailSDU( QueueNodeDef *pNode, t_uchar *Buff, int Len, char *MessageBuf ) { int RetStatus = RM_SUCCESS; XFailErrorCode XFailType = Buff[EXT_RESULT_CODE]; #ifdef RM_HEAP char *TempBuf = (char *)Mem_Allocate( MAX_LENGTH_STR ); #else char TempBuf[MAX_LENGTH_STR]; #endif QueueNodeDef *pHead = QueueGetHead(SEND_QUEUE); VRM_StateDef *Statistics = (VRM_StateDef *)(pHead->Message.DataBuffer); RetStatus = Resp_CheckCommandType( pNode, Buff, Len, MessageBuf ); switch( XFailType ) //Page APP-124 { case NO_RESPONSE: //ASCII 'A' //No response from network Statistics->XFAIL_CODE.NO_RESPONSE++; Statistics->LAST_UPDATED_FIELD = POS_NO_RESPONSE; sprintf( TempBuf, "%s\b No response from network\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("No response from network", "", 0); break; case NACK: //ASCII 'B' //Negative ACK received Statistics->XFAIL_CODE.NACK++; Statistics->LAST_UPDATED_FIELD = POS_NACK; sprintf( TempBuf, "%s\b Negative ACK received\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("Negative ACK received", "", 0); break; case HOST_DOWN: //ASCII 'C' //Host down Statistics->XFAIL_CODE.HOST_DOWN++; Statistics->LAST_UPDATED_FIELD = POS_HOST_DOWN; sprintf( TempBuf, "%s\b Host down\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("Host down", "", 0); break; case NOT_REGISTERED: //ASCII 'D' //VRM 500 not registered Statistics->XFAIL_CODE.NOT_REGISTERED++; Statistics->LAST_UPDATED_FIELD = POS_NOT_REGISTERED; sprintf( TempBuf, "%s\b VRM 500 not registered\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("VRM 500 not registered", "", 0); break; case LOW_BATTERY: //ASCII 'E' //Low battery - cannot transmit Statistics->XFAIL_CODE.LOW_BATTERY++; Statistics->LAST_UPDATED_FIELD = POS_LOW_BATTERY; sprintf( TempBuf, "%s\b Low battery - cannot transmit\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("VRM 500 Low battery", "", 0); break; case IBQ_FULL: //ASCII 'F' //VRM 500 inbound queue full Statistics->XFAIL_CODE.IBQ_FULL++; Statistics->LAST_UPDATED_FIELD = POS_IBQ_FULL; sprintf( TempBuf, "%s\b VRM 500 inbound queue full\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("VRM 500 inbound queue full", "", 0); break; case TX_DISABLED: //ASCII 'G' //Radio transmitter disabled Statistics->XFAIL_CODE.TX_DISABLED++; Statistics->LAST_UPDATED_FIELD = POS_TX_DISABLED_XFAIL; sprintf( TempBuf, "%s\b Radio transmitter disabled\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("Radio transmitter disabled", "", 0); break; case BUSY: //ASCII 'H' //Resource unavalialible Statistics->XFAIL_CODE.BUSY++; Statistics->LAST_UPDATED_FIELD = POS_BUSY; sprintf( TempBuf, "%s\b Resource unavalialible\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("Resource unavalialible", "", 0); break; case NOT_AVAILABLE: //ASCII 'I' //Unimplemented service Statistics->XFAIL_CODE.NOT_AVAILABLE++; Statistics->LAST_UPDATED_FIELD = POS_NOT_AVAILABLE; sprintf( TempBuf, "%s\b Unimplemented service\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("Unimplemented service", "", 0); break; case HW_ERROR: //ASCII 'J' //Generic error Statistics->XFAIL_CODE.HW_ERROR++; Statistics->LAST_UPDATED_FIELD = POS_HW_ERROR; sprintf( TempBuf, "%s\b Generic error\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("Generic error", "", 0); break; case INVALID_MODE: //ASCII 'K' //Invalid mode of operation Statistics->XFAIL_CODE.INVALID_MODE++; Statistics->LAST_UPDATED_FIELD = POS_INVALID_MODE; sprintf( TempBuf, "%s\b Invalid mode of operation\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("Invalid mode of operation", "", 0); break; case NO_MESSAGES: //ASCII 'L' //No outbound messages avaliable Statistics->XFAIL_CODE.NO_MESSAGES++; Statistics->LAST_UPDATED_FIELD = POS_NO_MESSAGES; sprintf( TempBuf, "%s\b No outbound messages avaliable\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("No outbound messages avaliable", "", 0); break; case MSGS_PENDING: //ASCII 'M' //Cannnot execute command due to pending inbound messages Statistics->XFAIL_CODE.MSGS_PENDING++; Statistics->LAST_UPDATED_FIELD = POS_MSGS_PENDING; sprintf( TempBuf, "%s\b Cannnot execute command due to pending inbound messages\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("Cannnot execute command", "", 0); break; case SW_ERROR: //ASCII 'N' //Sofware error has occured Statistics->XFAIL_CODE.SW_ERROR++; Statistics->LAST_UPDATED_FIELD = POS_SW_ERROR; sprintf( TempBuf, "%s\b Sofware error has occured\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("Sofware error has occured", "", 0); break; case OUT_OF_RANGE: //ASCII 'O' //RF not in range Statistics->XFAIL_CODE.OUT_OF_RANGE++; Statistics->LAST_UPDATED_FIELD = POS_OUT_OF_RANGE; sprintf( TempBuf, "%s\b RF not in range\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("RF not in range", "", 0); break; case PACKET_ERROR: //ASCII 'Z' //SDU DATA corruption( only in confirmed mode ) Statistics->XFAIL_CODE.PACKET_ERROR++; Statistics->LAST_UPDATED_FIELD = POS_PACKET_ERROR; sprintf( TempBuf, "%s\b SDU DATA corruption( only in confirmed mode )\n", MessageBuf ); strcpy( MessageBuf, TempBuf );//for DOS compatability /* Terminal Error logger */ PrintError ("DATA corruption", "", 0); break; default: Statistics->XFAIL_CODE.UNDEFINED++; Statistics->LAST_UPDATED_FIELD = POS_UNDEFINED_XFAIL_CODE; sprintf( TempBuf, "%s\b UNKNOWN = %04X HEX\n", MessageBuf, XFailType ); strcpy( MessageBuf, TempBuf );//for DOS compatability break; }//end switch #ifdef RM_HEAP Mem__Free( TempBuf ); #endif return( RetStatus ); //Responce SDU }//end Resp_ProcessXfailSDU
byte * _object_Allocate ( int32 size, int32 allocType ) { return Mem_Allocate ( size, allocType ) ; }
// // Function: Rcv_ProcessHeap // // Description: Extract All Data SDU's from Heap and Insert Them Into Receive Queue // // Arguments: // // Name Type Direction Description // ----------- ----------- ----------- ----------------------------------- // UnProcessedData HeapBuffDef * IN Data buffer to process // // Return Values: // // Name Explanation // ----------- ---------------------------------------------------------------- // RetStatus Last Rcv_ProcessSDU status // static int Rcv_ProcessHeap( HeapBuffDef *UnProcessedData, DataRecord *pModemStatus ) { int RetStatus = RM_SUCCESS; int i; t_uchar *pCurr = UnProcessedData->DataBuffer; t_uchar *pEnd = UnProcessedData->DataBuffer + UnProcessedData->DataLength; #ifdef RM_HEAP t_uchar *Buff = (t_uchar *)Mem_Allocate(MAX_LENGTH_MSG); #else t_uchar Buff[MAX_LENGTH_MSG]; #endif while ( pCurr < pEnd ) { //Find SOH and EOT and copy data between to Buff[] ( include SOH and EOT ) //Decode Buff[] //Check integrity of Buff[] //If integruty is OK - process data of Buff[] //-- Find first SOH --------------------------------------------- while( (*pCurr) != SOH && pCurr < pEnd ) pCurr++; if ( pCurr >= pEnd ) //or Length <= 0 { //SOH no found - BAD DATA UnProcessedData->DataLength = 0; // RetStatus = RM_ERROR_NO_DATA; break; //No Data In UnProcessedData }//end if //-- Copy to buffer till EOT or end of Data --------------------- i=0; Buff[i++] = *pCurr; //*pCurr = SOH do{ pCurr++; Buff[i++] = *pCurr; }while( (*pCurr) != EOT && pCurr < pEnd ); if ( pCurr >= pEnd ) break; //No Data - It's OK. EOT may be in next packet //Shift My Heap for ONE message left ( i bytes left ) UnProcessedData->DataLength = Data_BuffShiftLeft( UnProcessedData->DataBuffer, i, UnProcessedData->DataLength ); //Adjust End and Current pCurr = UnProcessedData->DataBuffer; pEnd = UnProcessedData->DataBuffer + UnProcessedData->DataLength; //Replace DLE to normal character sequence //Not important SOH and EOT - they not DLE Data_DecodeSpecialCaraters( Buff, &i ); //Buff[] ==> [SOH][DATA][INTEGRITY][EOT] //Buff+1 ==> [DATA][INTEGRITY][EOT] //i-2 ==> [DATA][INTEGRITY] // [SOH] + [EOT] = 2 bytes if ( Data_CheckIntegrity( Buff+1, i-2 ) != RM_SUCCESS ) { PrintBuffer( "[E] RECEIVED BAD Buffer ( [SOH][DATA][INTEGRITY][EOT] ) :", Buff, i ); continue; //Bad SDU }//end if ////////////////////////////////////////////////// // And at last we can check SDU - what is it? //Buff[] ==> [SOH][DATA][INTEGRITY][EOT] //Buff+1 ==> [DATA][INTEGRITY][EOT] //i-4 ==> [DATA] // [SOH] + [INTEGRITY] + [EOT] = 4 bytes RetStatus = Rcv_ProcessSDU( pModemStatus, Buff+1, i-4 ); }//End While #ifdef RM_HEAP Mem__Free( Buff ); #endif return( RetStatus ); }//end Rcv_ProcessHeap