打开串口时输出更多日志
This commit is contained in:
parent
365bb2a26e
commit
a56080eb15
|
@ -35,6 +35,9 @@ public:
|
|||
void* State; // 用户状态数据。常用于批量端口操作时记录索引
|
||||
|
||||
Port();
|
||||
#ifndef TINY
|
||||
virtual ~Port();
|
||||
#endif
|
||||
|
||||
Port& Set(Pin pin); // 设置引脚
|
||||
bool Empty() const;
|
||||
|
@ -57,10 +60,6 @@ public:
|
|||
virtual String& ToStr(String& str) const;
|
||||
|
||||
protected:
|
||||
//Port() = default;
|
||||
#ifndef TINY
|
||||
virtual ~Port();
|
||||
#endif
|
||||
|
||||
// 配置过程,由Open调用,最后GPIO_Init
|
||||
virtual void OnOpen(void* param);
|
||||
|
|
|
@ -16,8 +16,14 @@ SerialPort::SerialPort(COM index, int baudRate)
|
|||
// 析构时自动关闭
|
||||
SerialPort::~SerialPort()
|
||||
{
|
||||
if(RS485) delete RS485;
|
||||
delete RS485;
|
||||
RS485 = nullptr;
|
||||
|
||||
delete Ports[0];
|
||||
Ports[0] = nullptr;
|
||||
|
||||
delete Ports[1];
|
||||
Ports[1] = nullptr;
|
||||
}
|
||||
|
||||
void SerialPort::Init()
|
||||
|
@ -70,12 +76,10 @@ void SerialPort::Set(byte parity, byte dataBits, byte stopBits)
|
|||
// 打开串口
|
||||
bool SerialPort::OnOpen()
|
||||
{
|
||||
debug_printf("Serial%d Open(%d, %d, %d, %d)\r\n", _index + 1, _baudRate, _parity, _dataBits, _stopBits);
|
||||
debug_printf("Serial%d Open(%d, %d, %d, %d) TX=P%c%d RX=P%c%d\r\n", _index + 1, _baudRate, _parity, _dataBits, _stopBits, _PIN_NAME(Pins[0]), _PIN_NAME(Pins[1]));
|
||||
|
||||
// 清空缓冲区
|
||||
//#if !(defined(STM32F0) || defined(GD32F150))
|
||||
Tx.Clear();
|
||||
//#endif
|
||||
Rx.SetCapacity(0x80);
|
||||
Rx.Clear();
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ enum Pin
|
|||
// 获取组和针脚
|
||||
#define _PORT(PIN) (1 << ((PIN) & (uint16_t)0x0F))
|
||||
#define _PIN(PIN) (PIN & 0x000F)
|
||||
#define _PIN_NAME(pin) ('A' + (pin >> 4)), (pin & 0x0F)
|
||||
#define _PIN_NAME(pin) (pin==P0 ? '_' : ('A' + (pin >> 4))), (pin==P0 ? '0' : (pin & 0x0F))
|
||||
|
||||
/* 串口定义 */
|
||||
enum COM
|
||||
|
|
Loading…
Reference in New Issue