2

Currently I am sending the UART the strings I want to log and reading it on the host with any terminal.

In order to reduce the logging time and hopefully the image size as well (my flash is tiny), I figured out that the strings are unused in the embedded system, so why storing them on the flash?

I want to implement a server, whom I can send a hashed-key of any string (for example - it's ROM address) and the string will be output to file or screen.

My questions are:

  1. How to create the key2string converter out of the image file (the OS is CMX, but can be answered generally)
  2. Is there a recomended way to generate image, that will know the strings addresses but will exclude them from ROM?
  3. Is there a known generic (open-source or other) that implemented a similar logger?

Thanks

4

2 回答 2

2

我建议以下方法,而不是保存硬编码的字符串,然后尝试散列答案并通过 UART 发送,然后以某种方式从结果图像中删除字符串。

只需发送错误代码的索引即可。PC 端可以查找该索引并确定该条件的字符串是什么。如果希望设备代码更清晰,索引可以是枚举。

例如:

enum errorStrings
{
   ES_valueOutOfLimits = 1,
   ES_wowItsGettingWarm = 2,
   ES_randomError = 3,
   ES_passwordFailure = 4
};

因此,如果您通过 向 UART 发送数据printf,您可以执行以下操作:

printf("%d\n",(int)ES_wowItsGettingWarm);

然后,您的 PC 软件只需将 UART 上的“2”解码为有用的字符串“哇,它变热了”。

这使固件很小,但您需要手动使包含枚举的文件和带有字符串的文件保持同步。

于 2013-07-22T21:44:48.133 回答
1

我的解决方案是发送文件名和行(应该是 14-20 字节)并在服务器端有一个源解析器,它将生成实际文本的映射。这样,实际代码将不包含“格式”字符串,而是每个文件的单个“文件名”字符串。此外,文件名可以很容易地用枚举替换(与替换代码中的每个字符串不同)以降低 COMM 吞吐量。

我希望示例伪代码将有助于澄清这个想法:

/* target code */
#define PRINT(format,...) send(__FILE__,__LINE__,__VA_ARGS__)
...

/* host code (c++) */
void PrintComm(istream& in)
{
    string fileName;
    int    line,nParams;
    int*   params;
    in>>fileName>>line>>nParams;
    if (nParams>0)
    {
        params = new int[nParams];
        for (int i=0; i<nParams; ++i)
            in>>params[i];
    }
    const char* format = FindFormat(fileName,line);
    ...
    delete[] params;
}
于 2013-07-29T14:12:19.093 回答