mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-23 13:42:55 +08:00
fix: The hex format string of decoder result, max length up to 256
This commit is contained in:
parent
e9478aa926
commit
2067d5973b
@ -87,8 +87,16 @@ Annotation::Annotation(const srd_proto_data *const pdata, DecoderStatus *status)
|
|||||||
|
|
||||||
//get numeric data
|
//get numeric data
|
||||||
if (pda->str_number_hex[0]){
|
if (pda->str_number_hex[0]){
|
||||||
strcpy(resItem->str_number_hex, pda->str_number_hex);
|
int str_len = strlen(pda->str_number_hex);
|
||||||
resItem->is_numeric = true;
|
|
||||||
|
if (str_len <= DECODER_MAX_DATA_BLOCK_LEN){
|
||||||
|
resItem->str_number_hex = (char*)malloc(str_len + 1);
|
||||||
|
|
||||||
|
if (resItem->str_number_hex != NULL){
|
||||||
|
strcpy(resItem->str_number_hex, pda->str_number_hex);
|
||||||
|
resItem->is_numeric = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_status->m_bNumeric |= resItem->is_numeric;
|
_status->m_bNumeric |= resItem->is_numeric;
|
||||||
|
@ -117,6 +117,7 @@ int AnnotationResTable::MakeIndex(const std::string &key, AnnotationSourceItem*
|
|||||||
|
|
||||||
item->cur_display_format = -1;
|
item->cur_display_format = -1;
|
||||||
item->is_numeric = false;
|
item->is_numeric = false;
|
||||||
|
item->str_number_hex = NULL;
|
||||||
newItem = item;
|
newItem = item;
|
||||||
|
|
||||||
int dex = m_indexs.size();
|
int dex = m_indexs.size();
|
||||||
@ -331,6 +332,8 @@ void AnnotationResTable::reset()
|
|||||||
{
|
{
|
||||||
//release all resource
|
//release all resource
|
||||||
for (auto p : m_resourceTable){
|
for (auto p : m_resourceTable){
|
||||||
|
if (p->str_number_hex)
|
||||||
|
free(p->str_number_hex);
|
||||||
delete p;
|
delete p;
|
||||||
}
|
}
|
||||||
m_resourceTable.clear();
|
m_resourceTable.clear();
|
||||||
|
@ -26,14 +26,14 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#define DECODER_MAX_DATA_BLOCK_LEN 35
|
#define DECODER_MAX_DATA_BLOCK_LEN 256
|
||||||
#define CONVERT_STR_MAX_LEN 150
|
#define CONVERT_STR_MAX_LEN 150
|
||||||
|
|
||||||
struct AnnotationSourceItem
|
struct AnnotationSourceItem
|
||||||
{
|
{
|
||||||
bool is_numeric;
|
bool is_numeric;
|
||||||
char str_number_hex[DECODER_MAX_DATA_BLOCK_LEN]; //numerical value hex format string
|
char *str_number_hex; //numerical value hex format string
|
||||||
long long numberic_value;
|
|
||||||
std::vector<QString> src_lines; //the origin source string lines
|
std::vector<QString> src_lines; //the origin source string lines
|
||||||
std::vector<QString> cvt_lines; //the converted to bin/hex/oct format string lines
|
std::vector<QString> cvt_lines; //the converted to bin/hex/oct format string lines
|
||||||
int cur_display_format; //current format as bin/ex/oct..., init with -1
|
int cur_display_format; //current format as bin/ex/oct..., init with -1
|
||||||
|
@ -1704,13 +1704,11 @@ namespace pv
|
|||||||
_protocol_widget->update_view_status();
|
_protocol_widget->update_view_status();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DSV_MSG_COLLECT_END:
|
case DSV_MSG_COLLECT_END:
|
||||||
dsv_info("Mainwindow:DSV_MSG_COLLECT_END");
|
|
||||||
prgRate(0);
|
prgRate(0);
|
||||||
_view->repeat_unshow();
|
_view->repeat_unshow();
|
||||||
_view->on_state_changed(true);
|
_view->on_state_changed(true);
|
||||||
_protocol_widget->update_view_status();
|
_protocol_widget->update_view_status();
|
||||||
dsv_info("Mainwindow-end:DSV_MSG_COLLECT_END");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DSV_MSG_END_COLLECT_WORK:
|
case DSV_MSG_END_COLLECT_WORK:
|
||||||
|
@ -369,6 +369,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "IDS_MSG_DEVICE_BUSY_SWITCH_FAILED",
|
"id": "IDS_MSG_DEVICE_BUSY_SWITCH_FAILED",
|
||||||
"text": "设置在使用中,切换失败!"
|
"text": "设备在使用中,切换失败!"
|
||||||
}
|
}
|
||||||
]
|
]
|
@ -26,7 +26,7 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <log/xlog.h>
|
#include <log/xlog.h>
|
||||||
|
|
||||||
#define DECODE_NUM_HEX_MAX_LEN 35
|
#define DECODE_NUM_HEX_MAX_LEN 256
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -132,6 +132,7 @@ static int py_parse_ann_data(PyObject *list_obj, char ***out_strv, int list_size
|
|||||||
nstr = strlen(str) - 1;
|
nstr = strlen(str) - 1;
|
||||||
if (nstr > 0 && nstr < DECODE_NUM_HEX_MAX_LEN){
|
if (nstr > 0 && nstr < DECODE_NUM_HEX_MAX_LEN){
|
||||||
strcpy(hex_str_buf, str + 1);
|
strcpy(hex_str_buf, str + 1);
|
||||||
|
|
||||||
str[0] = '\n'; //set ignore flag
|
str[0] = '\n'; //set ignore flag
|
||||||
str[1] = 0;
|
str[1] = 0;
|
||||||
}
|
}
|
||||||
@ -241,7 +242,7 @@ static int convert_annotation(struct srd_decoder_inst *di, PyObject *obj,
|
|||||||
|
|
||||||
pda->str_number_hex[0] = 0;
|
pda->str_number_hex[0] = 0;
|
||||||
ann_text = NULL;
|
ann_text = NULL;
|
||||||
pda->numberic_value = 0;
|
pda->numberic_value = 0;
|
||||||
|
|
||||||
if (py_parse_ann_data(py_tmp, &ann_text, ann_size, pda->str_number_hex, &pda->numberic_value) != SRD_OK) {
|
if (py_parse_ann_data(py_tmp, &ann_text, ann_size, pda->str_number_hex, &pda->numberic_value) != SRD_OK) {
|
||||||
srd_err("Protocol decoder %s submitted annotation list, but "
|
srd_err("Protocol decoder %s submitted annotation list, but "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user