Пример #1
0
void tGpsAntennaProxy::RequestGPSConfiguration()
{
    unsigned char deviceAddress;

    if( GetDeviceAddress(deviceAddress) == true)
    {
        m_NDP2k.SendIsoRequest( 65293, m_NDP2k.MainVirtualDeviceIndex(), deviceAddress );
    }
}
Пример #2
0
int HDDownloadBlkCard::DownloadBlackCard(BYTE addflag,KSGDeviceNode* node
        ,KSGDeviceNode::Task* task)
{
    int ret = TASK_ERR_COMMON;
    try
    {

        int cardid = task->GetParams().GetParamIntVal(XML_KEY_CARDID);
        std::string version = task->GetParams().GetParam(XML_KEY_VERNUM);
        KSGDeviceNode* task_node = task->GetDeviceNode();
        unsigned short addr;
        addr = GetDeviceAddress(task->GetDeviceNode());
        HD8583STRUCT req;
        req.Init();
        req.SetFieldValue(FIELD_ADDRESS,addr);
        req.SetFieldValue(FIELD_TERMINALID,task_node->GetTermId());
        unsigned long encode_ver = EncodeVersionNum(version.c_str());
        req.SetFieldValue(FIELD_VERSIONOFLIST,encode_ver);
        char data[256] = "";
        ACE_OS::memset(data,0,sizeof data);
        data[0] = addflag;
        INT_2_BUF(cardid,data+1);
        req.SetFieldValue(FIELD_ADDITIONALDATA2,data,5);
        data[0] = 0x01;
        req.SetFieldValue(FIELD_ADDITIONALDATA3,data,1);
        ACE_OS::memset(data,0,sizeof data);
        ACE_HANDLE handler = ACE_INVALID_HANDLE;
        ACE_Time_Value tv = KSGGetTaskTimeoutIntval();
        int recvlen = -1;
        size_t packlen;
        handler = task->_handle;
        if((packlen = PackRequestStruct(req,MT_UPDATELIST2,data,sizeof data,true)) == 0)
        {
            // 错误的数据包
            ret = TASK_ERR_COMMON;
        }
        else if(HDSendBuffer(handler,data,packlen,&tv))
        {
            ret = TASK_ERR_TIMEOUT;
        }
        else if((recvlen = HDRecvBuffer(handler,data,sizeof data,&tv)) <= 0)
        {
            ret = TASK_ERR_TIMEOUT;
        }
        else
        {
            HD8583STRUCT resp;
            MESSAGETYPE msg_type;
            if(UnPackResponseStruct(resp,&msg_type,data,(size_t)recvlen))
            {
                ret = TASK_ERR_EXECUTE;
            }
            else if( (req->Address != resp->Address)
                     || (req->VerOfList != resp->VerOfList))
            {
                ret = TASK_ERR_EXECUTE;
            }
            else
            {
                KSGTaskResponse &tresp = task->GetResponse();
                tresp.AddField(XML_KEY_CARDID,cardid);
                char version_str[14] = "";
                DecodeVersionNum(resp->VerOfList,version_str);
                tresp.AddField(XML_KEY_VERNUM,version_str);
                ACE_DEBUG((LM_DEBUG,"更新设备黑名单版本成功id[%d][%s]"
                           ,task_node->GetDevId(),version_str));
                ret = TASK_SUCCESS;
            }
        }
        task->SetNeedResponse();
        return ret;
    }
    catch(KeyNotFoundException& )
    {
        return TASK_ERR_COMMON;
    }
    catch(...)
    {
        return TASK_ERR_COMMON;
    }
}
Пример #3
0
//*****************************************************************************
// execute callback for microrl library
// do what you want here, but don't write to argv!!! read only!!
int execute (int argc, const char * const * argv)
{
	int i = 0;
	// just iterate through argv word and compare it with your commands
	while (i < argc) {
		if (strcmp (argv[i], _CMD_HELP) == 0) {
			print ("microrl v");
			print (MICRORL_LIB_VER);
			print (" library STM32 v");
			print (Version);
			print("\n\r");
			print_help ();        // print help
		} else if (strcmp (argv[i], _CMD_CLEAR) == 0) {
			print ("\033[2J");    // ESC seq for clear entire screen
			print ("\033[H");     // ESC seq for move cursor at left-top corner
		} else if (strcmp (argv[i], _CMD_STATUS) == 0) {
			PrintStorageStatus();
			return 0;
		} else if (strcmp (argv[i], _CMD_STORAGE) == 0) {
			PrintConentStorage();
			return 0;
		} else if (strcmp (argv[i], _CMD_ERASE) == 0) {
			EraseStorage();
			return 0;
		} else if ( strcmp(argv[i], _CMD_SET_CARRIER_FREQ) == 0 ){

			if ( ++i < argc) {
				size_t freq = atoi(argv[i]);
				SetCarrierFrequency(freq);
			} else {
				print("Not enough arguments\n\r");
				return -1;
			}
			return 0;

		} else if ( strcmp(argv[i], _CMD_SET_SND_TMT) == 0 ){

			if ( ++i < argc) {
				TimeoutSndPackets = atof(argv[i]) / PLC_TIMER_PERIOD;
			} else {
				print("Not enough arguments\n\r");
				return -1;
			}

			return 0;

		} else if ( strcmp(argv[i], _CMD_SET_IR_SND_TMT) == 0 ){

			if ( ++i < argc) {
				TimeoutSndIrCodes = atof(argv[i]) / PLC_TIMER_PERIOD;
			} else {
				print("Not enough arguments\n\r");
				return -1;
			}

			return 0;

		} else if ( strcmp(argv[i], _CMD_SET_CHANNEL_VALUE) == 0 ) {

			if (++i < argc) {
				unsigned char channel = atoi(argv[i]);

				if (channel > MaxChannelNumber) {
					print("Channel number out of range\n\r");
					return -1;
				}

				if (++i < argc) {
					unsigned char value = atoi(argv[i]);

					if (value > 1) {
						printf("Channel value out of range\n\r");
						return -1;
					}

					SetOutValueToChannel(channel, value);
					return 0;
				}
			}

			print("Not enough arguments\n\r");
			return -1;

		} else if (strcmp (argv[i], _CMD_SHOW_PARAM) == 0) {
			printf("Network address: %u\n\r", (unsigned int) GetDeviceAddress());
			printf("Device type: %u\n\r", (unsigned int) GetDeviceType());
			printf("Ir debug mode: %u\n\r", (unsigned int)DebugModeIr);
			printf("Max length delta: %u\n\r", (unsigned int)LengthDelataMax);
			printf("Max interval delta: %u\n\r", (unsigned int)IntervalDelataMax);
			printf("Host snd timeout (in plc resolution): %u\n\r", (unsigned int) TimeoutSndPackets);
			printf("Ir snd timeout (in plc resolution): %u\n\r", (unsigned int) TimeoutSndIrCodes);
			return 0;
		} else {
			print ("command: '");
			print ((char*)argv[i]);
			print ("' Not found.\n\r");
		}
		i++;
	}
	return 0;
}