itas109 / CommLite

CommLite 是一款基于CSerialPort的文本UI串口调试助手 CommLite is a textual user interface serial communication tool
Other
16 stars 5 forks source link

click Exit segmentation fault 点击exit出现段错误 #2

Open itas109 opened 4 years ago

itas109 commented 4 years ago

Describe the bug click Exit segmentation fault 点击exit出现段错误

To Reproduce Steps to reproduce the behavior: click Exit button

Screenshots

$ ./commlite 
段错误 (核心已转储)

Desktop (please complete the following information):

itas109 commented 4 years ago

maybe sigslot's problem

itas109 commented 3 years ago
class mySlot : public has_slots<>
{
public:
    mySlot(CSerialPort * sp)
    {
        recLen = -1;
        p_sp = sp; 
    };

    void OnSendMessage()
    {
        //read
        recLen = p_sp->readAllData(str);

        if(recLen > 0)
        {
            if(!isShowHex)
            {
                str[recLen] = '\0';
                bodymsg(str);
            }
            else
            {
                for (int i = 0; i < recLen; i++)
                {
                    snprintf(hexChar,sizeof(hexChar), "%02X ", str[i] & 0xFF);// two bit hex +  one bit space + '\0'
                    hexChar[sizeof(hexChar)-1] = '\0';
                    bodymsg(hexChar);
                }
            }
        }
    };

private:
    mySlot(){};

private:
    CSerialPort * p_sp;

    int recLen;
    char hexChar[4];// two bit hex +  one bit space + '\0'
    char str[1024];
};
CSerialPort m_serialPort;
mySlot receive(&m_serialPort);