• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ printHex函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中printHex函数的典型用法代码示例。如果您正苦于以下问题:C++ printHex函数的具体用法?C++ printHex怎么用?C++ printHex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了printHex函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: dumpRegs

static void dumpRegs(struct ft5x06_ts *ts, unsigned start, unsigned end)
{
	u8 regbuf[512];
	unsigned char startch[1] = { start };
	int ret ;
	struct i2c_msg readpkt[2] = {
		{ts->client->addr, 0, 1, startch},
		{ts->client->addr, I2C_M_RD, end-start+1, regbuf}
	};
	ret = i2c_transfer(ts->client->adapter, readpkt, ARRAY_SIZE(readpkt));
	if (ret != ARRAY_SIZE(readpkt)) {
		printk(KERN_WARNING "%s: i2c_transfer failed\n", client_name);
	} else {
		printk(KERN_ERR "registers %02x..%02x\n", start, end);
		printHex(regbuf, end-start+1);
	}
}
开发者ID:Moretti0,项目名称:gg,代码行数:17,代码来源:ft5x06_ts.c


示例2: cmd_peep

void cmd_peep(void) {
int i=0;

	while (i <= ENDEEPROM) {
		if (!(i&63)) {speol(); printHex(i+0xe000); spb(':'); }
		if (!(i&7)) spb(' ');
		if (!(i&3)) spb(' ');		
		byte c = eeread(i) & 0xff;

		if (c == 0) spb('\\');
		//else if ((c == 255) || (c < 0)) spb('.');
		else if (c == 255) spb('.');
		else if (c < ' ') spb('^');
		else spb(c);
		i++;
	}
	speol();
}
开发者ID:mujtabachang,项目名称:mew,代码行数:18,代码来源:bitlash-eeprom.c


示例3: cgmiTestUserDataBufferCB

static cgmi_Status cgmiTestUserDataBufferCB(void *pUserData, void *pBuffer)
{
#if GST_CHECK_VERSION(1,0,0)
    GstMapInfo map;
#endif
    GstBuffer *pGstBuff = (GstBuffer *)pBuffer;
    guint8 *bufferData;
    guint bufferSize;

    if( NULL == pGstBuff )
    {
        return CGMI_ERROR_BAD_PARAM;
    }

#if GST_CHECK_VERSION(1,0,0)
    if ( gst_buffer_map(pGstBuff, &map, GST_MAP_READ) == FALSE )
    {
        g_print("Failed in mapping buffer for reading userdata!\n");
        return CGMI_ERROR_FAILED;
    }

    bufferData = map.data;
    bufferSize = map.size;
#else
    bufferData = GST_BUFFER_DATA( pGstBuff );
    bufferSize = GST_BUFFER_SIZE( pGstBuff );
#endif

    // Dump data recieved.
    g_print("cgmiTestUserDataBufferCB called with buffer of size (%d)...\n",
        bufferSize);
    printHex( bufferData, bufferSize );
    g_print("\n");

#if GST_CHECK_VERSION(1,0,0)
    gst_buffer_unmap( pGstBuff, &map );
#endif
    // Free buffer
    gst_buffer_unref( pGstBuff );

    gUserDataCbCalled++;

    return CGMI_ERROR_SUCCESS;
}
开发者ID:ertos12,项目名称:cgmi,代码行数:44,代码来源:cgmiClientTest.c


示例4: Macro_timeState

// Update Time State trigger
// Only valid with Sleep/Resume and Inactive/Active triggers
// States:
//   * 0x00 - Off
//   * 0x01 - Activate
//   * 0x02 - On
//   * 0x03 - Deactivate
void Macro_timeState( uint8_t type, uint16_t cur_time, uint8_t state )
{
	// Make sure this is a valid trigger type
	switch ( type )
	{
	case TriggerType_Sleep1:
	case TriggerType_Resume1:
	case TriggerType_Inactive1:
	case TriggerType_Active1:
		break;

	// Ignore if not the correct type
	default:
		warn_msg("Invalid time state trigger update: ");
		printHex( type );
		print(NL);
		return;
	}

	// cur_time is controlled by the caller
	// When this function called the trigger is active
	if ( cur_time > 0xFF )
	{
		warn_msg("Only 255 time instances are accepted for a time state trigger: ");
		printInt16( cur_time );
		print(NL);
		return;
	}
	uint8_t index = cur_time;

	// Only add to macro trigger list if one of three states
	switch ( state )
	{
	case ScheduleType_A:  // Activate
	case ScheduleType_On: // On
	case ScheduleType_D:  // Deactivate
		macroTriggerEventBuffer[ macroTriggerEventBufferSize ].index = index;
		macroTriggerEventBuffer[ macroTriggerEventBufferSize ].state = state;
		macroTriggerEventBuffer[ macroTriggerEventBufferSize ].type  = type;
		macroTriggerEventBufferSize++;
		break;
	}
}
开发者ID:nptchang,项目名称:controller,代码行数:50,代码来源:macro.c


示例5: cgmi_SectionBufferCallback_PMT

static cgmi_Status cgmi_SectionBufferCallback_PMT(
    void *pUserData,
    void *pFilterPriv,
    void *pFilterId,
    cgmi_Status sectionStatus,
    char *pSection,
    int sectionSize)
{
    cgmi_Status retStat;
    tMpegTsPmt curPmt;

    //g_print( "cgmi_QueryBufferCallback -- pFilterId: 0x%08lx \n", pFilterId );

    if( NULL == pSection )
    {
        g_print("NULL buffer passed to cgmiSectionBufferCallback.\n");
        return CGMI_ERROR_BAD_PARAM;
    }

    g_print("Received section pFilterId: %p, sectionSize %d\n\n", pFilterId, sectionSize);
    printHex( pSection, sectionSize );
    g_print("\n\n");

    parsePMT( &curPmt, pSection, sectionSize );
    printPMT( &curPmt );

    gPmtParsed = true;

    g_print("Calling cgmi_StopSectionFilter...\n");
    retStat = cgmi_StopSectionFilter( pFilterPriv, pFilterId );
    CHECK_ERROR(retStat);

    /*
    g_print("Calling cgmi_DestroySectionFilter...\n");
    retStat = cgmi_DestroySectionFilter( pFilterPriv, pFilterId );
    CHECK_ERROR(retStat);
    */
    // Free buffer allocated in cgmi_QueryBufferCallback
    g_free( pSection );


    return CGMI_ERROR_SUCCESS;
}
开发者ID:ertos12,项目名称:cgmi,代码行数:43,代码来源:cgmiClientTest.c


示例6: wmain

int wmain(int argc, wchar_t * argv[])
{
	RPC_BINDING_HANDLE hBinding;
	wchar_t dataIn[] = L"a cleartext message!";
	PVOID pDataOut, pDataOut2;
	DWORD dwDataOut, dwDataOut2;

	if(argc > 1)
	{
		wprintf(L"Will use \'%s\' for DC name...\n", argv[1]);
		if(kull_m_rpc_createBinding(L"ncacn_np", argv[1], L"\\pipe\\protected_storage", L"ProtectedStorage", RPC_C_IMP_LEVEL_IMPERSONATE, &hBinding, NULL))
		{
			wprintf(L"\n* Retrieve RSA Public Key\n");
			if(kull_m_rpc_bkrp_generic(&hBinding, &BACKUPKEY_RETRIEVE_BACKUP_KEY_GUID, (PVOID) 0xbadc00fe, 0, &pDataOut, &dwDataOut)) // don't ask me why dummy data is needed here (not used).
			{
				wprintf(L"  > pDataOut @ 0x%p (%u)\n", pDataOut, dwDataOut);
				//printHex(pDataOut, dwDataOut);
				MIDL_user_free(pDataOut);
			}

			wprintf(L"\n* Backup a secret (%s)\n", dataIn);
			if(kull_m_rpc_bkrp_generic(&hBinding, &BACKUPKEY_BACKUP_GUID, &dataIn, sizeof(dataIn), &pDataOut, &dwDataOut))
			{
				wprintf(L"  > pDataOut @ 0x%p (%u)\n", pDataOut, dwDataOut);
				printHex(pDataOut, dwDataOut);

				wprintf(L"\n* Restore a secret\n");
				if(kull_m_rpc_bkrp_generic(&hBinding, &BACKUPKEY_RESTORE_GUID, pDataOut, dwDataOut, &pDataOut2, &dwDataOut2))
				{
					wprintf(L"  > pDataOut2 @ 0x%p (%u)\n", pDataOut, dwDataOut);
					wprintf(L"  > Secret : %s\n", pDataOut2);
					MIDL_user_free(pDataOut2);
				}
				MIDL_user_free(pDataOut);
			}

			kull_m_rpc_deleteBinding(&hBinding);
		}
	}
	else wprintf(L"[ERROR] A DC name is needed in argument\n");
	return ERROR_SUCCESS;
}
开发者ID:gentilkiwi,项目名称:basic_rpc,代码行数:42,代码来源:test_call.c


示例7: nvmem_write_patch

unsigned char nvmem_write_patch(unsigned long ulFileId, unsigned long spLength, const uint8_t *spData)
{
	unsigned char 	status = 0;
	unsigned short	offset = 0;
	unsigned char*      spDataPtr = (unsigned char*)spData;
	uint8_t rambuffer[SP_PORTION_SIZE];

	while ((status == 0) && (spLength >= SP_PORTION_SIZE))
	{
	  for (uint8_t i=0; i<SP_PORTION_SIZE; i++) {
	    rambuffer[i] = pgm_read_byte(spData + i + offset);
	  }
#if (DEBUG_MODE == 1)
	  PRINT_F("Writing: "); printDec16(offset); PRINT_F("\t");
	  for (uint8_t i=0; i<SP_PORTION_SIZE; i++) {
	    PRINT_F("0x");
	    printHex(rambuffer[i]);
	    PRINT_F(", ");
	  }
	  PRINT_F("\n\r");
#endif
	  status = nvmem_write(ulFileId, SP_PORTION_SIZE, offset, rambuffer);
	  offset += SP_PORTION_SIZE;
	  spLength -= SP_PORTION_SIZE;
	  spDataPtr += SP_PORTION_SIZE;
	}
	
	if (status !=0)
	{
		// NVMEM error occurred
		return status;
	}
	
	if (spLength != 0)
	{
	  memcpy_P(rambuffer, spDataPtr, SP_PORTION_SIZE);
	  // if reached here, a reminder is left
	  status = nvmem_write(ulFileId, spLength, offset, rambuffer);
	}
	
	return status;
}
开发者ID:glocklueng,项目名称:stm32-wifi-ir,代码行数:42,代码来源:nvmem.c


示例8: nvmem_write_patch

UINT8 nvmem_write_patch(UINT32 ulFileId, UINT32 spLength, const UINT8 *spData)
{
	UINT8 	status = 0;
	UINT16	offset = 0;
	UINT8*      spDataPtr = (UINT8*)spData;
	UINT8 rambuffer[SP_PORTION_SIZE];

	while ((status == 0) && (spLength >= SP_PORTION_SIZE))
	{
	  for (UINT8 i=0; i<SP_PORTION_SIZE; i++) {
	    rambuffer[i] = pgm_read_byte(spData + i + offset);
	  }
#if (DEBUG_MODE == 1)
	  PRINT_F("Writing: "); printDec16(offset); PRINT_F("\t");
	  for (UINT8 i=0; i<SP_PORTION_SIZE; i++) {
	    PRINT_F("0x");
	    printHex(rambuffer[i]);
	    PRINT_F(", ");
	  }
	  PRINT_F("\n\r");
#endif
	  status = nvmem_write(ulFileId, SP_PORTION_SIZE, offset, rambuffer);
	  offset += SP_PORTION_SIZE;
	  spLength -= SP_PORTION_SIZE;
	  spDataPtr += SP_PORTION_SIZE;
	}
	
	if (status !=0)
	{
		// NVMEM error occurred
		return status;
	}
	
	if (spLength != 0)
	{
	  memcpy_P(rambuffer, spDataPtr, SP_PORTION_SIZE);
	  // if reached here, a reminder is left
	  status = nvmem_write(ulFileId, spLength, offset, rambuffer);
	}
	
	return status;
}
开发者ID:joshbouganim,项目名称:Adafruit_CC3000_Library,代码行数:42,代码来源:nvmem.cpp


示例9: selectPrintln

/*
**-----------------------------------------------------------------------------
**
**  Abstract:
**  This function selects according to which type of element to print
**  the function to send the data via UART. A new line character is added
**
**  Parameters:
**  string: data to be sent via UART
**  typeString: selects whether it is string, decimal or hex
**
**  Returns:
**  True:  Successful UART transmission
**  False: Unsuccessful UART transmission
**
**-----------------------------------------------------------------------------
*/
bool selectPrintln(uint8_t * string, uint8_t typeString)
{
  bool result = false;

  switch(typeString){
    case TYPE_STRING:
      result = printString(string, WITH_LINE);
      break;
    case TYPE_HEX:
      result = printHex((uint8_t)string, WITH_LINE);
      break;
    case TYPE_DEC:
      result = printDec((uint8_t)string, WITH_LINE);
      break;
    default:
      break;
  }
  
  return result;
}
开发者ID:NordicSemiconductor,项目名称:ble-sdk-RL78,代码行数:37,代码来源:CG_serial.c


示例10: syscallHandler

void syscallHandler(uint32_t eax, uint32_t ebx){
	switch(eax){
		case 0:
			;char c = (char)ebx;
			putch(c);
			break;
		case 1:
			;char* c2 = (char*)ebx;
			print(c2);
			break;
		case 2:
			__kill__();
			break;
		default:
			print("Other syscall ");
			printHex(eax);
			println("");
			break;
	}
}
开发者ID:Codepixl,项目名称:codeOS2,代码行数:20,代码来源:syscall.c


示例11: while

/**	Transmit a packet with checksum to the SM130.
 */
void SM130::transmitData()
{
	// wait until at least 20ms passed since last I2C transmission
	while(t > millis());
	t = millis() + 20;

	// init checksum and packet length
	byte sum = 0;
	byte len = data[0] + 1;

	// remember which command was sent
	cmd = data[1];

	// transmit packet with checksum
	//Wire.beginTransmission(address);
	for (int i = 0; i < len; i++)
	{
#if defined(ARDUINO) && ARDUINO >= 100
		Wire.write(data[i]);
#else
		Wire.send(data[i]);
#endif
		sum += data[i];
	}
#if defined(ARDUINO) && ARDUINO >= 100
	Wire.write(sum);
#else
	Wire.send(sum);
#endif
	Wire.endTransmission();

	// show transmitted packet for debugging
	if (debug)
	{
		Serial.print("> ");
		printArrayHex(data, len);
		Serial.print(' ');
		printHex(sum);
		Serial.println();
	}
}
开发者ID:cperez36,项目名称:RFIDuino,代码行数:43,代码来源:SM130.cpp


示例12: printHex

void printHex(Print& p, const uint8_t* buf, size_t len, const __FlashStringHelper* byte_sep, const __FlashStringHelper* group_sep, size_t group_by) {
	size_t cur_group = 0;
	while (len--) {
		// Print the group separator whenever starting a new
		// group
		if (group_by && group_sep && cur_group == group_by) {
			p.print(group_sep);
			cur_group = 0;
		}

		// Print the byte separator, except when at the start of
		// a new group (this also excludes the first byte)
		if (cur_group != 0 && byte_sep)
			p.print(byte_sep);

		printHex(p, *buf);

		buf++;
		cur_group++;
	}
}
开发者ID:Introsys,项目名称:fresh,代码行数:21,代码来源:Printers.cpp


示例13: fail

void fail() // segfault generation
{
    // int *p = 0x00000000;   
    // p[0] = 13;
    const int _m_size = 25;
    char * _m_array;
    // _m_array = new int [_m_size];
    _m_array = new char[_m_size];
    for (int i = 0; i<_m_size; i++)
    {
        //int a=rand() % my_array.size();
       
        _m_array[i] = rand() % _m_size;
        cout << i <<  " - " << _m_array[i];
        printHex(_m_array[i]);
        // cout << "\n";
    }
    cout << endl;
    delete [] _m_array;
        
}
开发者ID:MakSim345,项目名称:MS-VC08,代码行数:21,代码来源:my_exceptions.cpp


示例14: printData

void printData(
	const char *label,
	CFDataRef data,
	PrintDataType whichType,
	OidParser &parser)
{
	const unsigned char *buf = CFDataGetBytePtr(data);
	unsigned len = CFDataGetLength(data);
	
	printf("%s: ", label);
	switch(whichType) {
		case PD_Hex:
			printHex(buf, len, 16);
			break;
		case PD_ASCII:
			printAscii((const char *)buf, len, 50);
			break;
		case PD_OID:
			printOid(buf, len, parser);
	}
	putchar('\n');
}
开发者ID:unofficial-opensource-apple,项目名称:Security,代码行数:22,代码来源:rootUtils.cpp


示例15: PRINTLN

bool EmbitLoRaModem::Send(LoRaPacket* packet, bool ack)
{
	unsigned char length = packet->Write(sendBuffer);
	PRINTLN("Sending payload: ");
	for (unsigned char i = 0; i < length; i++) {
		printHex(sendBuffer[i]);
	}
	PRINTLN();
  
	if(ack == true)
		SendPacket(CMD_SEND_PREFIX, sizeof(CMD_SEND_PREFIX), sendBuffer, length);
	else
		SendPacket(CMD_SEND_PREFIX_NO_ACK, sizeof(CMD_SEND_PREFIX_NO_ACK), sendBuffer, length);
	unsigned char result = ReadPacket(3);
	if(result != 0){
		PRINTLN("Failed to send packet");
		return false;
	}
	else
		return true;
	
}
开发者ID:allthingstalk,项目名称:arduino-lora,代码行数:22,代码来源:EmbitLoRaModem.cpp


示例16: nvmem_write

signed long 
nvmem_write(unsigned long ulFileId, unsigned long ulLength, unsigned long 
						ulEntryOffset, unsigned char *buff)
{
	long iRes;
	unsigned char *ptr;
	unsigned char *args;
	
	iRes = EFAIL;
	
	ptr = tSLInformation.pucTxCommandBuffer;
	args = (ptr + SPI_HEADER_SIZE + HCI_DATA_CMD_HEADER_SIZE);
	
	// Fill in HCI packet structure
	args = UINT32_TO_STREAM(args, ulFileId);
	args = UINT32_TO_STREAM(args, 12);
	args = UINT32_TO_STREAM(args, ulLength);
	args = UINT32_TO_STREAM(args, ulEntryOffset);
	
	memcpy((ptr + SPI_HEADER_SIZE + HCI_DATA_CMD_HEADER_SIZE + 
					NVMEM_WRITE_PARAMS_LEN),buff,ulLength);
#if (DEBUG_MODE == 1)
	PRINT_F("Writing:\t");
	for (uint8_t i=0; i<ulLength; i++) {
	    PRINT_F("0x");
	    printHex(buff[i]);
	    PRINT_F(", ");
	}
	PRINT_F("\n\r");
#endif
	// Initiate a HCI command but it will come on data channel
	hci_data_command_send(HCI_CMND_NVMEM_WRITE, ptr, NVMEM_WRITE_PARAMS_LEN,
												ulLength);
	
	SimpleLinkWaitEvent(HCI_EVNT_NVMEM_WRITE, &iRes);
	
	return(iRes);
}
开发者ID:pscholl,项目名称:CC3000Patch,代码行数:38,代码来源:nvmem.cpp


示例17: SignCreate

int SignCreate(RSA *privkey, char *data, int dataLen, char *signature, int *signature_len) {
    unsigned int signLen = 0;
    int ret = 0;
    char *buf = NULL;
    
    char *hash =(char *) malloc(SHA512_DIGEST_LENGTH);
    
    if (hash != NULL) {
        SHA512((const unsigned char *)data, dataLen, (unsigned char *)hash);

        ret = RSA_sign(NID_sha512, (const unsigned char *)hash, SHA512_DIGEST_LENGTH, (unsigned char *)signature, &signLen, privkey);

        if (ret == 1) {  
            printHex("SIGNATURE", (const unsigned char *)signature, signLen); 
            *signature_len = signLen;
            ret = 1;
        }

        free(hash);
    }
    
    return ret;
}
开发者ID:aventado,项目名称:clockwork,代码行数:23,代码来源:signing.cpp


示例18: bunny24_bruteForce

void bunny24_bruteForce(bit plain[block_length] , bit crypt[block_length]){
	
	unsigned int i, end = 1024 * 1024 * 16;
	
	bit test[block_length];
	bit testp[block_length];
	
	for(i = 0; i < end; i++)
	{
		arrayCopy(plain , testp , 24);
		int j;
		for(j = 0; j < 24; j++)
		{
			if(i & (1 << j))
				test[j] = 1;
			else
				test[j] = 0;
			
		}
		
		//printArray(test , 24);
		
		bunny24_encrypt(testp , test);
		
		if(arrayEqual(testp , crypt , 24) == 0)
		{
			printHex(test , 24);
			return;
		}
		
		//printf("fail key %d \n " , i);
		
	}
	
	
}
开发者ID:parzio,项目名称:crypto-secure-communication,代码行数:36,代码来源:Bunny24.c


示例19: Connect_rx_process

void Connect_rx_process( uint8_t uartNum )
{
	// Determine current position to read until
	uint16_t bufpos = 0;
	switch ( uartNum )
	{
	DMA_BUF_POS( 0, bufpos );
	DMA_BUF_POS( 1, bufpos );
	}

	// Process each of the new bytes
	// Even if we receive more bytes during processing, wait until the next check so we don't starve other tasks
	while ( bufpos != uart_rx_buf[ uartNum ].last_read )
	{
		// If the last_read byte is at the buffer edge, roll back to beginning
		if ( uart_rx_buf[ uartNum ].last_read == 0 )
		{
			uart_rx_buf[ uartNum ].last_read = UART_Buffer_Size;

			// Check to see if we're at the boundary
			if ( bufpos == UART_Buffer_Size )
				break;
		}

		// Read the byte out of Rx DMA buffer
		uint8_t byte = uart_rx_buf[ uartNum ].buffer[ UART_Buffer_Size - uart_rx_buf[ uartNum ].last_read-- ];

		if ( Connect_debug )
		{
			printHex( byte );
			print(" ");
		}

		// Process UART byte
		switch ( uart_rx_status[ uartNum ].status )
		{
		// Every packet must start with a SYN / 0x16
		case UARTStatus_Wait:
			if ( Connect_debug )
			{
				print(" Wait ");
			}
			uart_rx_status[ uartNum ].status = byte == 0x16 ? UARTStatus_SYN : UARTStatus_Wait;
			break;

		// After a SYN, there must be a SOH / 0x01
		case UARTStatus_SYN:
			if ( Connect_debug )
			{
				print(" SYN ");
			}
			uart_rx_status[ uartNum ].status = byte == 0x01 ? UARTStatus_SOH : UARTStatus_Wait;
			break;

		// After a SOH the packet structure may diverge a bit
		// This is the packet type field (refer to the Command enum)
		// For very small packets (e.g. IdRequest) this is all that's required to take action
		case UARTStatus_SOH:
		{
			if ( Connect_debug )
			{
				print(" SOH ");
			}

			// Check if this is actually a reserved CMD 0x16 (Error condition)
			if ( byte == Command_SYN )
			{
				uart_rx_status[ uartNum ].status = UARTStatus_SYN;
				break;
			}

			// Otherwise process the command
			if ( byte < Command_TOP )
			{
				uart_rx_status[ uartNum ].status = UARTStatus_Command;
				uart_rx_status[ uartNum ].command = byte;
				uart_rx_status[ uartNum ].bytes_waiting = 0xFFFF;
			}
			// Invalid packet type, ignore
			else
			{
				uart_rx_status[ uartNum ].status = UARTStatus_Wait;
			}

			// Check if this is a very short packet
			switch ( uart_rx_status[ uartNum ].command )
			{
			case IdRequest:
				Connect_receive_IdRequest( 0, (uint16_t*)&uart_rx_status[ uartNum ].bytes_waiting, uartNum );
				uart_rx_status[ uartNum ].status = UARTStatus_Wait;
				break;

			default:
				if ( Connect_debug )
				{
					print(" ### ");
					printHex( uart_rx_status[ uartNum ].command );
				}
				break;
			}
//.........这里部分代码省略.........
开发者ID:rhinoceraptor,项目名称:controller,代码行数:101,代码来源:connect_scan.c


示例20: Connect_receive_ScanCode

uint8_t Connect_receive_ScanCode( uint8_t byte, uint16_t *pending_bytes, uint8_t uart_num )
{
	// Check the directionality
	if ( uart_num == UART_Master )
	{
		erro_print("Invalid ScanCode direction...");
	}

	// Master node, trigger scan codes
	if ( Connect_master ) switch ( (*pending_bytes)-- )
	{
	// Byte count always starts at 0xFFFF
	case 0xFFFF: // Device Id
		Connect_receive_ScanCodeDeviceId = byte;
		break;

	case 0xFFFE: // Number of TriggerGuides in bytes (byte * 3)
		*pending_bytes = byte * sizeof( TriggerGuide );
		Connect_receive_ScanCodeBufferPos = 0;
		break;

	default:
		// Set the specific TriggerGuide entry
		((uint8_t*)&Connect_receive_ScanCodeBuffer)[ Connect_receive_ScanCodeBufferPos++ ] = byte;

		// Reset the BufferPos if higher than sizeof TriggerGuide
		// And send the TriggerGuide to the Macro Module
		if ( Connect_receive_ScanCodeBufferPos >= sizeof( TriggerGuide ) )
		{
			Connect_receive_ScanCodeBufferPos = 0;

			// Adjust ScanCode offset
			if ( Connect_receive_ScanCodeDeviceId > 0 )
			{
				// Check if this node is too large
				if ( Connect_receive_ScanCodeDeviceId >= InterconnectNodeMax )
				{
					warn_msg("Not enough interconnect layout nodes configured: ");
					printHex( Connect_receive_ScanCodeDeviceId );
					print( NL );
					break;
				}

				// This variable is in generatedKeymaps.h
				extern uint8_t InterconnectOffsetList[];
				Connect_receive_ScanCodeBuffer.scanCode = Connect_receive_ScanCodeBuffer.scanCode + InterconnectOffsetList[ Connect_receive_ScanCodeDeviceId - 1 ];
			}

			// ScanCode receive debug
			if ( Connect_debug )
			{
				dbug_msg("");
				printHex( Connect_receive_ScanCodeBuffer.type );
				print(" ");
				printHex( Connect_receive_ScanCodeBuffer.state );
				print(" ");
				printHex( Connect_receive_ScanCodeBuffer.scanCode );
				print( NL );
			}

			// Send ScanCode to macro module
			Macro_interconnectAdd( &Connect_receive_ScanCodeBuffer );
		}

		break;
	}
	// Propagate ScanCode packet
	// XXX It would be safer to buffer the scancodes first, before transmitting the packet -Jacob
	//     The current method is the more efficient/aggressive, but could cause issues if there were errors during transmission
	else switch ( (*pending_bytes)-- )
	{
	// Byte count always starts at 0xFFFF
	case 0xFFFF: // Device Id
	{
		Connect_receive_ScanCodeDeviceId = byte;

		// Lock the master Tx buffer
		uart_lockTx( UART_Master );

		// Send header + Id byte
		uint8_t header[] = { 0x16, 0x01, ScanCode, byte };
		Connect_addBytes( header, sizeof( header ), UART_Master );
		break;
	}
	case 0xFFFE: // Number of TriggerGuides in bytes
		*pending_bytes = byte * sizeof( TriggerGuide );
		Connect_receive_ScanCodeBufferPos = 0;

		// Pass through byte
		Connect_addBytes( &byte, 1, UART_Master );
		break;

	default:
		// Pass through byte
		Connect_addBytes( &byte, 1, UART_Master );

		// Unlock Tx Buffer after sending last byte
		if ( *pending_bytes == 0 )
			uart_unlockTx( UART_Master );
		break;
//.........这里部分代码省略.........
开发者ID:rhinoceraptor,项目名称:controller,代码行数:101,代码来源:connect_scan.c



注:本文中的printHex函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ printIndent函数代码示例发布时间:2022-05-30
下一篇:
C++ printHelp函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap