Skip to content

Commit

Permalink
Update Ruby version 10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PetruSoroaga committed Dec 24, 2024
1 parent 357cfd6 commit 818b573
Show file tree
Hide file tree
Showing 213 changed files with 8,113 additions and 8,311 deletions.
56 changes: 32 additions & 24 deletions Makefile

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions code/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ typedef u32 __le32;
#define LOGGER_MESSAGE_QUEUE_ID 123

#define SYSTEM_NAME "Ruby"
// dword: BB.BB.MM.mm (BB.BB: build number, MM: major ver, mm: minor ver)
// dword[3...0]: BB.BB.MM.mm (BB.BB: build number (highest bytes), MM: major ver, mm: minor ver (lowest byte))
#define SYSTEM_SW_VERSION_MAJOR 10
#define SYSTEM_SW_VERSION_MINOR 0
#define SYSTEM_SW_BUILD_NUMBER 245
#define SYSTEM_SW_VERSION_MINOR 10
#define SYSTEM_SW_BUILD_NUMBER 252

#if __BYTE_ORDER == __LITTLE_ENDIAN
#define le16_to_cpu(x) (x)
Expand Down
5 changes: 2 additions & 3 deletions code/base/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const char* commands_get_description(u8 command_type)
case COMMAND_ID_SET_RADIO_CARD_MODEL: strcpy(szCommandDesc, "Set_Radio_Card_Model"); break;
case COMMAND_ID_SET_MODEL_FLAGS: strcpy(szCommandDesc, "Set_Model_Flags"); break;
case COMMAND_ID_SET_SIK_PACKET_SIZE: strcpy(szCommandDesc, "Set_SiK_Packet_Size"); break;
case COMMAND_ID_RESET_RADIO_LINK: strcpy(szCommandDesc, "Reset_Radio_Link"); break;
case COMMAND_ID_RESET_RADIO_LINK: strcpy(szCommandDesc, "Reset_Radio_Link"); break;
case COMMAND_ID_SET_AUTO_TX_POWERS: strcpy(szCommandDesc, "SetAutoTxPowers"); break;
case COMMAND_ID_GET_USB_INFO: strcpy(szCommandDesc, "Get_USB_Info"); break;
case COMMAND_ID_SET_RADIO_LINK_CAPABILITIES: strcpy(szCommandDesc, "Set_Radio_Link_Capabilities"); break;
case COMMAND_ID_GET_USB_INFO2: strcpy(szCommandDesc, "Get_USB_Info2"); break;
Expand Down Expand Up @@ -86,8 +87,6 @@ const char* commands_get_description(u8 command_type)
case COMMAND_ID_SET_NICE_VALUE_TELEMETRY: strcpy(szCommandDesc, "Set_NiceValueTelemetry"); break;
case COMMAND_ID_SET_NICE_VALUES: strcpy(szCommandDesc, "Set_NiceValues"); break;
case COMMAND_ID_SET_IONICE_VALUES: strcpy(szCommandDesc, "Set_IONiceValues"); break;
case COMMAND_ID_SET_RADIO_SLOTTIME: strcpy(szCommandDesc, "Set_Radio_Slottime"); break;
case COMMAND_ID_SET_RADIO_THRESH62: strcpy(szCommandDesc, "Set_Radio_Thresh62"); break;
case COMMAND_ID_SET_ENABLE_DHCP: strcpy(szCommandDesc, "Set_Enable_DHCP"); break;
case COMMAND_ID_SET_ALL_PARAMS: strcpy(szCommandDesc, "Set_All_Params"); break;
case COMMAND_ID_GET_ALL_PARAMS_ZIP: strcpy(szCommandDesc, "Get_All_Params_Zip"); break;
Expand Down
19 changes: 11 additions & 8 deletions code/base/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
#define COMMAND_ID_SET_VEHICLE_NAME 3

#define COMMAND_ID_SET_TX_POWERS 4
// 8 bytes: 0...5: u8 RTL8812AU, u8 RTL8812EU, u8 Atheros, u8 maxRTL8812AU, u8 maxRTL8812EU, u8 maxAtheros,
// 6: u8 radio card index,
// 7: u8 power, if 0 -> not set
// First 8 bytes can be 0xFF or 0x00 for no changes in those params
// Byte 9,10,11 (if present, optional): 0x81 then tx power Sik, then 0x81
// byte 0: count interfaces
// N-bytes: power for each card (raw power values)

// deprecated starting in 8.3, using now test link functionality to change frequency for 2.4/5.8ghz. still using this command for 433/868 bands
#define COMMAND_ID_SET_RADIO_LINK_FREQUENCY 5
Expand All @@ -34,10 +31,16 @@
#define COMMAND_ID_SET_RADIO_LINK_FLAGS_CONFIRMATION 8
// param is radio link id

#define COMMAND_ID_SET_RADIO_SLOTTIME 9
#define COMMAND_ID_SET_RADIO_THRESH62 10
#define COMMAND_ID_SET_AUTO_TX_POWERS 9
// param: byte 0: auto adjust vehicle power
// param: byte 1: auto adjust controller power

// Deprecated in 10.1
//#define COMMAND_ID_SET_RADIO_THRESH62 10

#define COMMAND_ID_SET_RADIO_CARD_MODEL 11
// param: low byte: card index, second byte: card model
// param: low byte: card index, second byte: card model (if 0xFF, then autodetect it again)
// response has the new card model in command_response_param

#define COMMAND_ID_SET_MODEL_FLAGS 12
// param u32 new model flags
Expand Down
213 changes: 110 additions & 103 deletions code/base/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,45 +67,46 @@ int getChannels25Count() { return sizeof(channels25)/sizeof(channels25[0]); }
u32* getChannels58() { return channels58; }
int getChannels58Count() { return sizeof(channels58)/sizeof(channels58[0]); }

int _getChannelsAndCount(u32 nBand, u32** channels)
int _getChannelsAndCount(u32 nBand, u32** ppuChannels)
{
if( channels == NULL )
if (ppuChannels == NULL)
return -1;

switch ( nBand ) {
switch ( nBand )
{
case RADIO_HW_SUPPORTED_BAND_433:
*channels = getChannels433();
*ppuChannels = getChannels433();
return getChannels433Count();

case RADIO_HW_SUPPORTED_BAND_868:
*channels = getChannels868();
*ppuChannels = getChannels868();
return getChannels868Count();

case RADIO_HW_SUPPORTED_BAND_915:
*channels = getChannels915();
*ppuChannels = getChannels915();
return getChannels915Count();

case RADIO_HW_SUPPORTED_BAND_23:
*channels = getChannels23();
*ppuChannels = getChannels23();
return getChannels23Count();

case RADIO_HW_SUPPORTED_BAND_24:
*channels = getChannels24();
*ppuChannels = getChannels24();
return getChannels24Count();

case RADIO_HW_SUPPORTED_BAND_25:
*channels = getChannels25();
*ppuChannels = getChannels25();
return getChannels25Count();

case RADIO_HW_SUPPORTED_BAND_58:
*channels = getChannels58();
*ppuChannels = getChannels58();
return getChannels58Count();

default:
break;
}

*channels = NULL;
*ppuChannels = NULL;
return -1;
}

Expand Down Expand Up @@ -150,12 +151,15 @@ int getBand(u32 freqKhz)

int getChannelIndexForFrequency(u32 nBand, u32 freqKhz)
{
u32* channels = NULL;
int channelcount = _getChannelsAndCount(nBand, &channels);
if( channels != NULL ) {
for( int i=0; i<channelcount; i++ )
if ( freqKhz == channels[i] )
u32* puChannels = NULL;
int iChannelcount = _getChannelsAndCount(nBand, &puChannels);
if( puChannels != NULL )
{
for( int i=0; i<iChannelcount; i++ )
{
if ( freqKhz == puChannels[i] )
return i;
}
}
return -1;
}
Expand Down Expand Up @@ -212,7 +216,8 @@ int getSupportedChannels(u32 supportedBands, int includeSeparator, u32* pOutChan
if ( NULL == pOutChannels || 0 == maxChannels )
return 0;

int radio_hw_supported_bands[] = {
int radio_hw_supported_bands[] =
{
RADIO_HW_SUPPORTED_BAND_433,
RADIO_HW_SUPPORTED_BAND_868,
RADIO_HW_SUPPORTED_BAND_915,
Expand All @@ -222,32 +227,33 @@ int getSupportedChannels(u32 supportedBands, int includeSeparator, u32* pOutChan
RADIO_HW_SUPPORTED_BAND_58
};

int countSupported = 0;
int iCountSupported = 0;
for( int r=0; r < sizeof(radio_hw_supported_bands)/sizeof(radio_hw_supported_bands[0]); r++ )
{
u32* channels;
int channelcount = _getChannelsAndCount(supportedBands & radio_hw_supported_bands[r], &channels);
if( channels != NULL ) {
for( int i=0; i<channelcount; i++ )
u32* puChannels = NULL;
int iChannelsCount = _getChannelsAndCount(supportedBands & radio_hw_supported_bands[r], &puChannels);
if( puChannels != NULL )
{
for( int i=0; i<iChannelsCount; i++ )
{
*pOutChannels = channels[i];
*pOutChannels = puChannels[i];
pOutChannels++;
countSupported++;
if ( countSupported >= maxChannels )
return countSupported;
iCountSupported++;
if ( iCountSupported >= maxChannels )
return iCountSupported;
}
if ( includeSeparator )
{
*pOutChannels = 0;
pOutChannels++;
countSupported++;
if ( countSupported >= maxChannels )
return countSupported;
iCountSupported++;
if ( iCountSupported >= maxChannels )
return iCountSupported;
}
}
}

return countSupported;
return iCountSupported;
}

int *getDataRatesBPS() { return s_WiFidataRates; }
Expand Down Expand Up @@ -525,109 +531,110 @@ FILE* try_open_base_version_file(char* szOutputFile)
return fd;
}

u32 s_uBaseRubyVersion = 0;

void get_Ruby_BaseVersion(int* pMajor, int* pMinor)
{
int iMajor = 0;
int iMinor = 0;
if ( NULL != pMajor )
*pMajor = 0;
if ( NULL != pMinor )
*pMinor = 0;

if ( 0 != s_uBaseRubyVersion )
{
if ( NULL != pMajor )
*pMajor = (s_uBaseRubyVersion >> 8) & 0xFF;
if ( NULL != pMinor )
*pMinor = s_uBaseRubyVersion & 0xFF;
return;
}

char szVersion[32];
szVersion[0] = 0;
char szFile[MAX_FILE_PATH_SIZE];
szFile[0] = 0;

FILE* fd = try_open_base_version_file(NULL);
if ( NULL != fd )
FILE* fd = try_open_base_version_file(szFile);
if ( NULL == fd )
{
if ( 1 != fscanf(fd, "%s", szVersion) )
szVersion[0] = 0;
fclose(fd);
log_softerror_and_alarm("[Config] Failed to open base Ruby version file (%s).", szFile);
return;
}
else
char szBuff[64];
if ( 1 != fscanf(fd, "%s", szBuff) )
{
if ( NULL != pMajor )
*pMajor = SYSTEM_SW_VERSION_MAJOR;
if ( NULL != pMinor )
*pMinor = 0;
fclose(fd);
log_softerror_and_alarm("[Config] Failed to read base Ruby version file (%s).", szFile);
return;
}
fclose(fd);
log_line("[Config] Read raw base Ruby version: [%s] from file (%s)", szBuff, szFile);

if ( 0 != szVersion[0] )
for( int i=0; i<(int)strlen(szBuff); i++ )
{
char* p = &szVersion[0];
while ( *p )
{
if ( isdigit(*p) )
iMajor = iMajor * 10 + ((*p)-'0');
if ( (*p) == '.' )
break;
p++;
}
if ( 0 != *p )
if ( szBuff[i] == '.' )
{
p++;
while ( *p )
{
if ( isdigit(*p) )
iMinor = iMinor * 10 + ((*p)-'0');
if ( (*p) == '.' )
break;
p++;
}
szBuff[i] = 0;
int iMajor = 0;
int iMinor = 0;
sscanf(szBuff, "%d", &iMajor);
sscanf(&szBuff[i+1], "%d", &iMinor);
s_uBaseRubyVersion = (((u32)iMajor) << 8) | ((u32)iMinor);
log_line("[Config] Parsed base Ruby version: %u.%u", (s_uBaseRubyVersion>>8) & 0xFF, s_uBaseRubyVersion & 0xFF);

if ( NULL != pMajor )
*pMajor = (s_uBaseRubyVersion >> 8) & 0xFF;
if ( NULL != pMinor )
*pMinor = s_uBaseRubyVersion & 0xFF;

return;
}
if ( iMinor > 9 )
iMinor = iMinor/10;
}
if ( NULL != pMajor )
*pMajor = iMajor;
if ( NULL != pMinor )
*pMinor = iMinor;
log_softerror_and_alarm("[Config] Failed to parse base Ruby version from file (%s).", szFile);
}

void get_Ruby_UpdatedVersion(int* pMajor, int* pMinor)
{
int iMajor = 0;
int iMinor = 0;
if ( NULL != pMajor )
*pMajor = 0;
if ( NULL != pMinor )
*pMinor = 0;

char szVersion[32];
szVersion[0] = 0;
char szBuff[64];
szBuff[0] = 0;

char szFile[MAX_FILE_PATH_SIZE];
strcpy(szFile, FOLDER_CONFIG);
strcat(szFile, FILE_INFO_LAST_UPDATE);

FILE* fd = fopen(szFile, "r");
if ( NULL != fd )
if ( NULL == fd )
return;

if ( 1 != fscanf(fd, "%s", szBuff) )
{
if ( 1 != fscanf(fd, "%s", szVersion) )
szVersion[0] = 0;
fclose(fd);
return;
}
fclose(fd);

log_line("[Config] Read update Ruby version: [%s] from file (%s)", szBuff, szFile);

if ( 0 != szVersion[0] )
for( int i=0; i<(int)strlen(szBuff); i++ )
{
char* p = &szVersion[0];
while ( *p )
if ( szBuff[i] == '.' )
{
if ( isdigit(*p) )
iMajor = iMajor * 10 + ((*p)-'0');
if ( (*p) == '.' )
break;
p++;
szBuff[i] = 0;
int iMajor = 0;
int iMinor = 0;
sscanf(szBuff, "%d", &iMajor);
sscanf(&szBuff[i+1], "%d", &iMinor);
log_line("[Config] Parsed updated Ruby version: %u.%u", iMajor, iMinor);

if ( NULL != pMajor )
*pMajor = iMajor;
if ( NULL != pMinor )
*pMinor = iMinor;

return;
}
if ( 0 != *p )
{
p++;
while ( *p )
{
if ( isdigit(*p) )
iMinor = iMinor * 10 + ((*p)-'0');
if ( (*p) == '.' )
break;
p++;
}
}
if ( iMinor > 9 )
iMinor = iMinor/10;
}
if ( NULL != pMajor )
*pMajor = iMajor;
if ( NULL != pMinor )
*pMinor = iMinor;
}
Loading

0 comments on commit 818b573

Please sign in to comment.