Merge pull request #11 from Tencent/master

2020/06/28merge
This commit is contained in:
Mculover666
2020-06-28 15:12:39 +08:00
committed by GitHub
14 changed files with 52 additions and 30 deletions

View File

@@ -654,7 +654,7 @@ bool RegionAS923TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
uint8_t RegionAS923LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed )
{
uint8_t status = 0x07;
RegionCommonLinkAdrParams_t linkAdrParams;
RegionCommonLinkAdrParams_t linkAdrParams = {0};
uint8_t nextIndex = 0;
uint8_t bytesProcessed = 0;
uint16_t chMask = 0;

View File

@@ -637,7 +637,7 @@ bool RegionAU915TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
uint8_t RegionAU915LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed )
{
uint8_t status = 0x07;
RegionCommonLinkAdrParams_t linkAdrParams;
RegionCommonLinkAdrParams_t linkAdrParams = {0};
uint8_t nextIndex = 0;
uint8_t bytesProcessed = 0;
uint16_t channelsMask[6] = { 0, 0, 0, 0, 0, 0 };

View File

@@ -556,7 +556,7 @@ bool RegionCN470TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
uint8_t RegionCN470LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed )
{
uint8_t status = 0x07;
RegionCommonLinkAdrParams_t linkAdrParams;
RegionCommonLinkAdrParams_t linkAdrParams = {0};
uint8_t nextIndex = 0;
uint8_t bytesProcessed = 0;
uint16_t channelsMask[6] = { 0, 0, 0, 0, 0, 0 };

View File

@@ -610,7 +610,7 @@ bool RegionCN779TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
uint8_t RegionCN779LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed )
{
uint8_t status = 0x07;
RegionCommonLinkAdrParams_t linkAdrParams;
RegionCommonLinkAdrParams_t linkAdrParams = {0};
uint8_t nextIndex = 0;
uint8_t bytesProcessed = 0;
uint16_t chMask = 0;

View File

@@ -610,7 +610,7 @@ bool RegionEU433TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
uint8_t RegionEU433LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed )
{
uint8_t status = 0x07;
RegionCommonLinkAdrParams_t linkAdrParams;
RegionCommonLinkAdrParams_t linkAdrParams = {0};
uint8_t nextIndex = 0;
uint8_t bytesProcessed = 0;
uint16_t chMask = 0;

View File

@@ -641,7 +641,7 @@ bool RegionEU868TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
uint8_t RegionEU868LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed )
{
uint8_t status = 0x07;
RegionCommonLinkAdrParams_t linkAdrParams;
RegionCommonLinkAdrParams_t linkAdrParams = {0};
uint8_t nextIndex = 0;
uint8_t bytesProcessed = 0;
uint16_t chMask = 0;

View File

@@ -627,7 +627,7 @@ bool RegionIN865TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
uint8_t RegionIN865LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed )
{
uint8_t status = 0x07;
RegionCommonLinkAdrParams_t linkAdrParams;
RegionCommonLinkAdrParams_t linkAdrParams = {0};
uint8_t nextIndex = 0;
uint8_t bytesProcessed = 0;
uint16_t chMask = 0;

View File

@@ -600,7 +600,7 @@ bool RegionKR920TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
uint8_t RegionKR920LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed )
{
uint8_t status = 0x07;
RegionCommonLinkAdrParams_t linkAdrParams;
RegionCommonLinkAdrParams_t linkAdrParams = {0};
uint8_t nextIndex = 0;
uint8_t bytesProcessed = 0;
uint16_t chMask = 0;

View File

@@ -608,7 +608,7 @@ bool RegionRU864TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
uint8_t RegionRU864LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed )
{
uint8_t status = 0x07;
RegionCommonLinkAdrParams_t linkAdrParams;
RegionCommonLinkAdrParams_t linkAdrParams = {0};
uint8_t nextIndex = 0;
uint8_t bytesProcessed = 0;
uint16_t chMask = 0;

View File

@@ -724,7 +724,7 @@ bool RegionUS915TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
uint8_t RegionUS915LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed )
{
uint8_t status = 0x07;
RegionCommonLinkAdrParams_t linkAdrParams;
RegionCommonLinkAdrParams_t linkAdrParams = {0};
uint8_t nextIndex = 0;
uint8_t bytesProcessed = 0;
uint16_t channelsMask[6] = { 0, 0, 0, 0, 0, 0 };

View File

@@ -54,7 +54,7 @@ summary_t summary = {
.is_safe_block_ignored = 0,
};
static int32_t offtin(uint8_t *buf)
static int32_t offtin_u32(uint8_t *buf)
{
int32_t y;
@@ -80,6 +80,26 @@ static uint16_t offtin_u16(uint8_t *buf)
return y;
}
static void offtout_u32(int32_t x, uint8_t *buf)
{
int32_t y;
if (x < 0) {
y = -x;
} else {
y = x;
}
buf[0] = y % 256; y -= buf[0];
y = y / 256; buf[1] = y % 256; y -= buf[1];
y = y / 256; buf[2] = y % 256; y -= buf[2];
y = y / 256; buf[3] = y % 256;
if (x < 0) {
buf[3] |= 0x80;
}
}
static void offtout_u16(uint16_t y, uint8_t *buf)
{
buf[0] = y % 256; y -= buf[0];
@@ -381,11 +401,11 @@ static int bspatch_parse(size_t oldsize, size_t newsize, size_t blk_len, uint8_t
int32_t ctl_from = 0, diff_from = 0, extra_from = 0;
uint8_t *ctl_blk, *diff_blk, *extra_blk;
ctl_len = offtin(patch);
ctl_len = offtin_u32(patch);
patch += sizeof(int32_t);
diff_len = offtin(patch);
diff_len = offtin_u32(patch);
patch += sizeof(int32_t);
new_len = offtin(patch);
new_len = offtin_u32(patch);
patch += sizeof(int32_t);
if (new_len != newsize) {
@@ -398,13 +418,13 @@ static int bspatch_parse(size_t oldsize, size_t newsize, size_t blk_len, uint8_t
while (ctl_from < ctl_len) {
/* read the original X, Y, Z from ctl block */
X = offtin(ctl_blk + ctl_from);
X = offtin_u32(ctl_blk + ctl_from);
ctl_from += sizeof(int32_t);
Y = offtin(ctl_blk + ctl_from);
Y = offtin_u32(ctl_blk + ctl_from);
ctl_from += sizeof(int32_t);
Z = offtin(ctl_blk + ctl_from);
Z = offtin_u32(ctl_blk + ctl_from);
ctl_from += sizeof(int32_t);
blk_info_build(X, Y, new_from, old_from, diff_from, extra_from, blk_len);
@@ -739,9 +759,10 @@ static int patch4block_assemble(int new_blk_idx, size_t blk_len, uint8_t *diff_b
*/
uint8_t X;
int is_diff_all_zeros = 0;
uint16_t I = (uint16_t)new_blk_idx, N = (uint16_t)new_blk_info->cmd_cnt, Y, Z;
uint32_t Z;
uint16_t I = (uint16_t)new_blk_idx, N = (uint16_t)new_blk_info->cmd_cnt, Y;
uint8_t header[FOLD_N(sizeof(uint16_t) / sizeof(uint8_t), 4)];
uint8_t buf[FOLD_N(sizeof(uint16_t) / sizeof(uint8_t), 1)];
uint8_t buf[FOLD_N(sizeof(uint32_t) / sizeof(uint8_t), 1)];
if ((diff = malloc(blk_len)) == NULL) {
ERROR("malloc failed!\n");
@@ -770,11 +791,11 @@ static int patch4block_assemble(int new_blk_idx, size_t blk_len, uint8_t *diff_b
ERROR("wstream full!\n");
}
offtout_u16(Y, buf);
if (wstream_write_stream(&ws, buf, sizeof(buf)) != 0) {
if (wstream_write_stream(&ws, buf, sizeof(uint16_t)) != 0) {
ERROR("wstream full!\n");
}
offtout_u16(Z, buf);
if (wstream_write_stream(&ws, buf, sizeof(buf)) != 0) {
offtout_u32(Z, buf);
if (wstream_write_stream(&ws, buf, sizeof(uint32_t)) != 0) {
ERROR("wstream full!\n");
}
@@ -794,7 +815,7 @@ static int patch4block_assemble(int new_blk_idx, size_t blk_len, uint8_t *diff_b
ERROR("wstream full!\n");
}
offtout_u16(Y, buf);
if (wstream_write_stream(&ws, buf, sizeof(buf)) != 0) {
if (wstream_write_stream(&ws, buf, sizeof(uint16_t)) != 0) {
ERROR("wstream full!\n");
}
@@ -1176,7 +1197,8 @@ static int patch_test(uint8_t *old, size_t oldsize, uint8_t *new, size_t newsize
copy Y bytes from the extra block
*/
uint8_t X;
uint16_t I, N, Y, Z, C, D;
uint32_t Z;
uint16_t I, N, Y, C, D;
uint8_t *ctrl_blk, *diff_blk, *extra_blk;
uint16_t cursor = 0, size2cmp = 0;
uint16_t old_idx, old_offset;
@@ -1203,7 +1225,7 @@ static int patch_test(uint8_t *old, size_t oldsize, uint8_t *new, size_t newsize
Y = offtin_u16(ctrl_blk);
ctrl_blk += sizeof(uint16_t);
Z = offtin_u16(ctrl_blk);
Z = offtin_u32(ctrl_blk);
ctrl_blk += sizeof(uint16_t);
old_idx = BLK_IDX(Z, blk_len);

View File

@@ -112,7 +112,7 @@ static void process_command_line(int argc, char **argv, diff_param_t *param, arg
param->block_len = 0;
while ((c = getopt(argc, argv, "vhb:n:o:")) != -1) {
while ((c = getopt(argc, argv, "vhsb:n:o:")) != -1) {
switch (c) {
case 'h':
usage();

View File

@@ -105,7 +105,7 @@ __API__ void tos_stopwatch_delay_ms(k_time_t millisec);
*
* @attention
*
* @param[in] stopwatch ticks remain.
* @param[in] stopwatch the stopwatch.
*
* @return ticks remain
*/
@@ -116,7 +116,7 @@ __API__ k_tick_t tos_stopwatch_remain(k_stopwatch_t *stopwatch);
*
* @attention
*
* @param[in] stopwatch milliseconds remain.
* @param[in] stopwatch the stopwatch.
*
* @return milliseconds remain
*/
@@ -127,7 +127,7 @@ __API__ k_time_t tos_stopwatch_remain_ms(k_stopwatch_t *stopwatch);
*
* @attention
*
* @param[in] stopwatch milliseconds remain.
* @param[in] stopwatch the stopwatch.
*
* @return whether the stopwatch is expired
* @retval #K_TRUE the stopwatch is expired.

View File

@@ -49,7 +49,7 @@ __API__ k_tick_t tos_systick_get(void);
*
* @param tick systick count to set
*
* @return tick count since boot
* @return None
*/
__API__ void tos_systick_set(k_tick_t tick);