|
|
@@ -10,7 +10,7 @@
|
|
|
#include "stm32f103.h"
|
|
|
#include "tc_tcu.h"
|
|
|
#include "tcXHHW.h"
|
|
|
-
|
|
|
+#include <ifaddrs.h>
|
|
|
// static int tcu_quit = 0;
|
|
|
|
|
|
// void sigint_handler(int sig)
|
|
|
@@ -65,6 +65,73 @@ char* formatAppVersion(void)
|
|
|
return app_version;
|
|
|
}
|
|
|
|
|
|
+char version[10] ="1.1.7";
|
|
|
+void printVersion(char* arg)
|
|
|
+{
|
|
|
+ int len;
|
|
|
+ static uint8_t comfire = 0;
|
|
|
+ char src_path[32] = {0};
|
|
|
+ if(comfire == 1)
|
|
|
+ {
|
|
|
+ printi("SW:%s\n",version);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ len = readlink(arg, src_path, sizeof(src_path) - 1);
|
|
|
+ comfire = 1;
|
|
|
+ if (len == -1) {
|
|
|
+ printi("this is sr_path %s:%s\n", arg,version);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ src_path[len] = '\0';
|
|
|
+ printi("SW:%s:%s\n", src_path,version);
|
|
|
+}
|
|
|
+
|
|
|
+int get_interface_ip(const char *ifname) {
|
|
|
+ struct ifaddrs *ifap, *ifa;
|
|
|
+ struct sockaddr_in *sa;
|
|
|
+ int found = 0;
|
|
|
+ char ip_buf[32];
|
|
|
+
|
|
|
+ if (ifname == NULL) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1. ???????????
|
|
|
+ if (getifaddrs(&ifap) == -1) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. ???????????? IPv4 ??
|
|
|
+ for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
|
|
|
+ // ?????
|
|
|
+ // - ?????
|
|
|
+ // - ???? IPv4?AF_INET?
|
|
|
+ // - ?????
|
|
|
+ if (strcmp(ifa->ifa_name, ifname) == 0 &&
|
|
|
+ ifa->ifa_addr != NULL &&
|
|
|
+ ifa->ifa_addr->sa_family == AF_INET) {
|
|
|
+
|
|
|
+ // ?? IPv4 ??
|
|
|
+ sa = (struct sockaddr_in *)ifa->ifa_addr;
|
|
|
+ inet_ntop(AF_INET, &(sa->sin_addr), ip_buf, 32);
|
|
|
+ printi("ip:%s\n",ip_buf);
|
|
|
+ found = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ freeifaddrs(ifap);
|
|
|
+
|
|
|
+ if (!found) {
|
|
|
+ printe("no ip\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
extern void rs232_test(int loop);
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
@@ -76,11 +143,15 @@ int main(int argc, char* argv[])
|
|
|
clog_init("/home/root/log/tcu", CLOG_BUFF_SIZE*60*24, 30);
|
|
|
tcu_BSP_init();
|
|
|
tcu_config_init(config_filename);
|
|
|
- printd("\n\r\tSW:%s\n", formatAppVersion());
|
|
|
-
|
|
|
+ // printd("\n\r\tSW:%s\n", formatAppVersion());
|
|
|
+
|
|
|
clog_bind_serverip(tcu_config.xhlog_ip, tcu_config.xhlog_port);
|
|
|
|
|
|
+ extern void print_stationID();
|
|
|
+ print_stationID();
|
|
|
+ printVersion(argv[0]);
|
|
|
|
|
|
+ get_interface_ip("eth0");
|
|
|
|
|
|
set_GUNLED_on(0, 0);
|
|
|
set_GUNLED_on(1, 0);
|