TT12-MCU/applications/main.c
CSSC-WORK\murmur e8a8606bf3 func.c 更新upSend函数,屏蔽打包操作
tools.c 更新time2Str函数 添加isInByte函数
ttmsg.c 屏蔽多处错误调用tcpInit(),更新匹配ack的逻辑
2023-07-20 15:29:37 +08:00

139 lines
3.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-04-27 RT-Thread first version
*/
#include <rtthread.h>
#define LOG_TAG "main"
#define LOG_LVL LOG_LVL_DBG
#include <ulog.h>
#include <board.h>
#include <ttmsg/ttmsg.h>
//#include <cfg.h>
int main(void)
{
//
// clock_information();
// #define LED_HEART GET_PIN(E,3)
/* 设置PIN脚模式为输出 */
rt_pin_mode(LED_HEART, PIN_MODE_OUTPUT);
rt_pin_mode(LED_HEART_DEBUG, PIN_MODE_OUTPUT);
rt_pin_mode(ETH_RESET_PIN, PIN_MODE_OUTPUT);
rt_pin_mode(TT_EN, PIN_MODE_OUTPUT);
rt_pin_mode(TR485_RE, PIN_MODE_OUTPUT);
rt_pin_write(TR485_RE, PIN_LOW);
// rt_pin_write(ETH_RESET_PIN, PIN_LOW);//关闭ETH
// rt_pin_write(TT_EN, PIN_HIGH);//关闭TT
while (1)
{
/* 拉低PIN脚 */
rt_pin_write(LED_HEART, PIN_LOW);
rt_pin_write(LED_HEART_DEBUG, PIN_HIGH);
/* 延时1ms省电 */
rt_thread_mdelay(10); //去掉延时共用print替换
// rt_kprintf("Heartbeat.\n");
/* 拉高PIN脚 */
rt_pin_write(LED_HEART, PIN_HIGH);
rt_pin_write(LED_HEART_DEBUG, PIN_LOW);
rt_thread_mdelay(1000);
// rt_device_control(wdg_dev, RT_DEVICE_CTRL_WDT_KEEPALIVE, NULL);
/* 从消息队列中读取消息*/
// rt_err_t result = rt_mq_recv(&update_cfg, &msg, sizeof(msg), RT_WAITING_NO);
// if (result == RT_EOK)
// {
// LOG_I("updatecfg:%10s -->%s", msg.key, msg.value);
// }
// rt_thread_mdelay(1000);
}
return RT_EOK;
}
//fastlz_test -c demo.bin f.bin
#ifdef DEMO
void pfdemo(void)
{
// #define cmb_println(...) rt_kprintf(__VA_ARGS__);rt_kprintf("\r\n");
// char *f = "1023_05_19_15_29_59_254.txt";
// char *f = "2023_05_19_15_29_59_255.txt";
char *f = "2023_06_16_10_28_00_123.bin";
static rt_uint8_t d[10][200] = { };
static rt_uint8_t s[10] = { };
rt_uint8_t len = 0;
LOG_D("%p--%p",d,s);
LOG_I("pack %s ...",f);
len = pack_File(f, 0, d, s);
rt_kprintf("len is %d\n", len);
if (len)
{
for (size_t var = 0; var < len; var++) {
LOG_HEX("d",27,d[var],s[var]);
}
// LOG_HEX("pkdata:",27,d[0],s[0]);
// LOG_D("%p--%p",d,s);
// LOG_D("%d--%d--%02X",len,s[0],d[0][0]);
LOG_I("Done.");
}
}
void pp(int argc, char **argv)
{
// if (argc == 2)
{
/* 创建线程 */
rt_thread_t thread = rt_thread_create("pmsg2", pfdemo, RT_NULL, 1024 * 10, 25, 10);
/* 创建成功则启动线程 */
if (thread != RT_NULL)
{
rt_thread_startup(thread);
// rt_kprintf("done");
}
else
{
LOG_E("thread 'pmsg' create failure.");
return RT_ERROR;
}
}
}
MSH_CMD_EXPORT(pp, );
#endif
INIT_APP_EXPORT(main);
extern int rt_hw_stm32_eth_init(void);
MSH_CMD_EXPORT(rt_hw_stm32_eth_init, );
void show_version(void)
{
char str[30];
uint8_t t[10];
size_t len=time2Byte(t);
bytes2str(t, len, 10, "", str);
rt_kprintf("SW Version: %s build%s\n","1.43",bytes2str(t, len, 10, "", str));
}
MSH_CMD_EXPORT(show_version,);
INIT_COMPONENT_EXPORT(show_version);