1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +01:00

Create ID from a hashed CPU serial number.

This commit is contained in:
Brian Webb 2012-04-07 19:41:23 -07:00
parent d39e89a096
commit e639d173a0
3 changed files with 12 additions and 3 deletions

View File

@ -48,7 +48,6 @@ struct pios_rfm22b_cfg {
uint8_t minPacketSize;
uint8_t txWinSize;
uint8_t maxConnections;
uint32_t id;
};
extern int32_t PIOS_RFM22B_Init(uint32_t *rfb22b_id, const struct pios_rfm22b_cfg *cfg);

View File

@ -99,6 +99,18 @@ void PIOS_Board_Init(void) {
#endif /* PIOS_INCLUDE_TIM */
#if defined(PIOS_INCLUDE_PACKET_HANDLER)
// Create our (hopefully) unique 32 bit id from the processor serial number.
uint32_t crc32 = 0;
{
char serial_no_str[33];
PIOS_SYS_SerialNumberGet(serial_no_str);
// Create a 32 bit value using 4 8 bit CRC values.
crc32 = PIOS_CRC_updateCRC(0, (uint8_t*)serial_no_str, 8) << 24;
crc32 |= PIOS_CRC_updateCRC(0, (uint8_t*)serial_no_str + 8, 8) << 16;
crc32 |= PIOS_CRC_updateCRC(0, (uint8_t*)serial_no_str + 16, 8) << 8;
crc32 |= PIOS_CRC_updateCRC(0, (uint8_t*)serial_no_str + 24, 8);
}
pios_ph_cfg.id = crc32;
pios_packet_handler = PHInitialize(&pios_ph_cfg);
#endif /* PIOS_INCLUDE_PACKET_HANDLER */

View File

@ -488,7 +488,6 @@ const struct pios_rfm22b_cfg pios_rfm22b_cfg = {
.minPacketSize = 50,
.txWinSize = 4,
.maxConnections = 1,
.id = 0x36249acb
};
#endif /* PIOS_INCLUDE_RFM22B */
@ -500,7 +499,6 @@ const struct pios_rfm22b_cfg pios_rfm22b_cfg = {
PacketHandlerConfig pios_ph_cfg = {
.txWinSize = PIOS_PH_TX_WIN_SIZE,
.maxConnections = PIOS_PH_MAX_CONNECTIONS,
.id = 0x36249acb,
};
#endif /* PIOS_INCLUDE_PACKET_HANDLER */