问题已经解决:在telnet数据反馈添加格式符号处理,遍历所有将要输出的数据BUF,取出每一条完整的字符串分别发送出去。
具体代码实现如下:
rt_uint8_t *send_ptr = RT_NULL;
rt_uint8_t *send_ptr_t = RT_NULL;
rt_uint8_t *send_ptr_t2 = RT_NULL;
rt_base_t level = rt_hw_interrupt_disable();
int send_len = rt_ringbuffer_peak(telnet.tx_rb, &send_ptr);
rt_hw_interrupt_enable(level);
if(send_len > 0)
{
send_ptr_t = send_ptr;
send_ptr_t2 = send_ptr;
m = 0;
for(i = 0; i < send_len; i++)
{
if(*send_ptr_t == '\n'){
memset(readbuf,'\0',512);
memcpy(readbuf, send_ptr_t2 + m, (i+1) - m);
if(readbuf[0] == '\n')
{
;
}
else if(readbuf[6] == '\n')
{
send(telnet.client_fd, readbuf, 6, 0);
}
else {
readbuf[(i+1) - m] = '\r';
readbuf[(i+2) - m] = '\n';
send(telnet.client_fd, readbuf, (i+2) - m, 0);
}
m = i + 1;
}
else if(*send_ptr_t == '\b')
{
memset(readbuf,'\0',512);
memcpy(readbuf, send_ptr_t2 + m, (i+1) - m);
readbuf[(i+1) - m] = '\r';
send(telnet.client_fd, readbuf, (i+2) - m, 0);
m = i + 1;
}
send_ptr_t++;
}
client_tick_timeout = rt_tick_get() + rt_tick_from_millisecond(telnet.client_timeout * 60000);
}
问题已经解决:在telnet数据反馈添加格式符号处理,遍历所有将要输出的数据BUF,取出每一条完整的字符串分别发送出去。
具体代码实现如下:
rt_uint8_t *send_ptr = RT_NULL;
rt_uint8_t *send_ptr_t = RT_NULL;
rt_uint8_t *send_ptr_t2 = RT_NULL;
rt_base_t level = rt_hw_interrupt_disable();
int send_len = rt_ringbuffer_peak(telnet.tx_rb, &send_ptr);
rt_hw_interrupt_enable(level);
if(send_len > 0)
{
send_ptr_t = send_ptr;
send_ptr_t2 = send_ptr;
m = 0;
for(i = 0; i < send_len; i++)
{
if(*send_ptr_t == '\n'){
memset(readbuf,'\0',512);
memcpy(readbuf, send_ptr_t2 + m, (i+1) - m);
if(readbuf[0] == '\n')
{
;
}
else if(readbuf[6] == '\n')
{
send(telnet.client_fd, readbuf, 6, 0);
}
else {
readbuf[(i+1) - m] = '\r';
readbuf[(i+2) - m] = '\n';
send(telnet.client_fd, readbuf, (i+2) - m, 0);
}
m = i + 1;
}
else if(*send_ptr_t == '\b')
{
memset(readbuf,'\0',512);
memcpy(readbuf, send_ptr_t2 + m, (i+1) - m);
readbuf[(i+1) - m] = '\r';
send(telnet.client_fd, readbuf, (i+2) - m, 0);
m = i + 1;
}
send_ptr_t++;
}
client_tick_timeout = rt_tick_get() + rt_tick_from_millisecond(telnet.client_timeout * 60000);
}
举报