|
@@ -90,40 +90,41 @@ static int DTU_uart2_init(void)
|
|
|
/*数据发送*/
|
|
/*数据发送*/
|
|
|
void DTU_Write(char *fmt, ...)
|
|
void DTU_Write(char *fmt, ...)
|
|
|
{
|
|
{
|
|
|
- const char dtu_conf[4] = {device_status.vol,0x00,0x00,0x00};
|
|
|
|
|
- va_list arg;
|
|
|
|
|
- static char dtu_str[800];
|
|
|
|
|
|
|
+ //static const char dtu_conf[4] = {device_status.vol,0x00,0x00,0x00};
|
|
|
|
|
+ va_list ap;
|
|
|
|
|
+ static char dtu_str[1024];
|
|
|
rt_size_t str_length;
|
|
rt_size_t str_length;
|
|
|
- va_start(arg,fmt);
|
|
|
|
|
- str_length = rt_vsnprintf(dtu_str, sizeof(dtu_str) - 1, fmt, arg);
|
|
|
|
|
- if (str_length > 800 - 1)
|
|
|
|
|
- str_length = 800 - 1;
|
|
|
|
|
|
|
+ va_start(ap,fmt);
|
|
|
|
|
+ //str_length = rt_vsnprintf(dtu_str, sizeof(dtu_str) - 1, fmt, arg);
|
|
|
|
|
+ str_length = rt_vsnprintf(dtu_str, sizeof(dtu_str) - 1, fmt, ap);
|
|
|
|
|
+ va_end(ap);
|
|
|
|
|
+ if (str_length > 1024 - 1)
|
|
|
|
|
+ str_length = 1024 - 1;
|
|
|
rt_device_write(dtuserial, 0, dtu_str, str_length);
|
|
rt_device_write(dtuserial, 0, dtu_str, str_length);
|
|
|
- if(strstr(dtu_str,"volume")!=RT_NULL)
|
|
|
|
|
- {
|
|
|
|
|
- rt_device_write(dtuserial,0,dtu_conf,4);
|
|
|
|
|
- }
|
|
|
|
|
- else if (strstr(dtu_str,"reset")!=RT_NULL) {
|
|
|
|
|
- const char dtu_conf[4] = {7,0x00,0x00,0x00};
|
|
|
|
|
- rt_device_write(dtuserial,0,dtu_conf,4);
|
|
|
|
|
- }
|
|
|
|
|
- va_end(arg);
|
|
|
|
|
- memset(dtu_str,'\0',sizeof(dtu_str));
|
|
|
|
|
|
|
+ rt_thread_mdelay(10);
|
|
|
|
|
+// if(strstr(dtu_str,"volume")!=RT_NULL)
|
|
|
|
|
+// {
|
|
|
|
|
+// rt_device_write(dtuserial,0,dtu_conf,4);
|
|
|
|
|
+// }
|
|
|
|
|
+// else if (strstr(dtu_str,"reset")!=RT_NULL) {
|
|
|
|
|
+// const char dtu_conf[4] = {7,0x00,0x00,0x00};
|
|
|
|
|
+// rt_device_write(dtuserial,0,dtu_conf,4);
|
|
|
|
|
+// }
|
|
|
}
|
|
}
|
|
|
/* 接收数据回调函数 */
|
|
/* 接收数据回调函数 */
|
|
|
static rt_err_t dtu_input(rt_device_t dev, rt_size_t size)
|
|
static rt_err_t dtu_input(rt_device_t dev, rt_size_t size)
|
|
|
{
|
|
{
|
|
|
- struct rx_msg msg;
|
|
|
|
|
- rt_err_t result;
|
|
|
|
|
- msg.dev = dev;
|
|
|
|
|
- msg.size = size;
|
|
|
|
|
- result = rt_mq_send(&rx_mq_dtu,&msg, sizeof(struct rx_msg));
|
|
|
|
|
- if ( result == -RT_EFULL)
|
|
|
|
|
- {
|
|
|
|
|
- /* 消息队列满 */
|
|
|
|
|
- rt_kprintf("message queue full!\n");
|
|
|
|
|
- }
|
|
|
|
|
- return result;
|
|
|
|
|
|
|
+ struct rx_msg msg;
|
|
|
|
|
+ rt_err_t result;
|
|
|
|
|
+ msg.dev = dev;
|
|
|
|
|
+ msg.size = size;
|
|
|
|
|
+ result = rt_mq_send(&rx_mq_dtu,&msg, sizeof(struct rx_msg));
|
|
|
|
|
+ if ( result == -RT_EFULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ /* 消息队列满 */
|
|
|
|
|
+ rt_kprintf("message queue full!\n");
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
/* 入口函数-指令接收*/
|
|
/* 入口函数-指令接收*/
|
|
|
static void dtu_thread_entry_recv(void *parameter)
|
|
static void dtu_thread_entry_recv(void *parameter)
|