From 891c915af6d5c0bc8ed669aa4dd2f2eb106bed57 Mon Sep 17 00:00:00 2001 From: shaun feakes Date: Fri, 16 Mar 2018 10:26:47 -0500 Subject: [PATCH] serial logger update --- release/aqualinkd.conf | 2 +- release/serial_logger | Bin 19976 -> 24156 bytes serial_logger.c | 34 ++++++++++++++++++++++------------ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/release/aqualinkd.conf b/release/aqualinkd.conf index debdee7..0acb193 100755 --- a/release/aqualinkd.conf +++ b/release/aqualinkd.conf @@ -41,7 +41,7 @@ override_freeze_protect = no # The id of the Aqualink terminal device. Devices probed by RS8 master are: # 08-0b, 10-13, 18-1b, 20-23, 28-2b, 30-33, 38-3b, 40-43 -# +# Working RS ID's are 0x0a 0x0b 0x09 0x08 <- 0x08 is usually taken device_id=0x0a diff --git a/release/serial_logger b/release/serial_logger index 967bbfebb9a7983dd1ef2c3c741d4e1085a30751..7993fdcf0c7d50c18939e03852452759be28c828 100755 GIT binary patch delta 7433 zcmb_heQ;IBbwBs&BSIhWBt3ngkN2*gKK&5V14#sgiUd|25eW|l8QcUY!~$bX12)*h zxYQ5xkzxiL++|YY5KH5_Q^v@xY`JcR$_{RcO^w{4Q!)Vtr~2SI1Ua?q;EYg&)!*;k zd!^MI|Ct@F&iU;*d-m+^*>m^acleZXz0Wvq1-k!CMB*i(RxFtz72=aZF+_GYSBo@P z8>lZX``(h3K&%N+7RaF?<4ai0XdOU9lPQwu$iYfdBddw};?UX|lgetDvB7(F?RMYQ z*AF)T%Yq*Uk6m1S=;fy`e%||*(PNqeO}$&J!;Z znk}-AG)Ka6kjxB`!=(8lM@ju6$4SdXPLPH~PLh_3oFXj|=^`x^d6g9VahfzJ(oI?^ z(nIPMd5bhz$mp`iU2Q_}L#_!hn z?Hb>q@#{3cUE|vvKFooeH9>>M*J^yF#+PV(fyR3^K2_u6HGcf|)Ff};?h8-O_)|@A zL*uV&{AG>r*ZA`q->30!X?(ZFzdFf>j}D!h1lR(NKdSKuHGZ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G)EwCCu`uMA-lalrYPCl10(&o&X<6R^&KNfZMR9t1v$8ml{~%kc8PlN9uS7mUl~-<>Z+t zw@H}g7uAV!SK2tP!uWI`W4wU}I45B?u%3VF&`K!6y%J`5OZG(hW(l+Wkc8R(Q3>D8 z3ih0d23!(md5whGzzPYo{G^0g-j^d@nCnUBkL^$iE&VqVX0XmHkZvOispIejV0Px%0;V@>lEZV-hxI};VgsK@>uFqkoq*A#}Y__ z_|3fQ)A<(y-p8@nr$2{2uhMZ)#=itbO#Smbv75cPHFULhG;hupldF>hOVHIwrYcTG zBQ7hWaISujE$AaUaMIYaQCR*j6TW1^$k^Jl&4(^~WCu11`UfZ(4SbR^b%pGS3bYNl zL_eDBz${?SfxWtZwMoAoc--Lxy5A&k=eg2LET5uBp}q(r21H=ocd@wdwn8pD zuoIY1QjM;^7dR0cvq{Hq02_s8=zSCZ4455cKVkxi=nIp=4<9w@!i12k_Q}E^HnAT8%=nJ33r3uh78R z^D=mz;w@teA^Gos`5rV5&>w&~NvzQI{{*}r_nAe^ZZXLhneZxLzVMoL{VptNO{B4elc)#|5dK%96&|1&9r&%Y7n_3z2$&4+ z06y;R`l{wHmag{~AGCHodQY9D>(tLKE0%^7acr3 #include #include +#include #include "aq_serial.h" #include "utils.h" #define SLOG_MAX 40 +#define PACKET_MAX 1000 typedef struct serial_id_log { unsigned char ID; @@ -18,13 +20,22 @@ typedef struct serial_id_log { bool _keepRunning = true; - +unsigned char _goodID[] = { 0x0a, 0x0b, 0x08, 0x09 }; void intHandler(int dummy) { _keepRunning = false; logMessage(LOG_NOTICE, "Stopping!"); } +bool canUse(unsigned char ID) +{ + int i; + for (i=0; i < strlen((char*)_goodID); i++ ) { + if (ID == _goodID[i]) + return true; + } + return false; +} int main(int argc, char *argv[]) { int rs_fd; @@ -35,6 +46,7 @@ int main(int argc, char *argv[]) { bool found; serial_id_log slog[SLOG_MAX]; int sindex = 0; + int received_packets=0; if (getuid() != 0) { fprintf(stderr, "ERROR %s Can only be run as root\n", argv[0]); @@ -59,6 +71,7 @@ int main(int argc, char *argv[]) { } packet_length = get_packet(rs_fd, packet_buffer); + if (packet_length == -1) { // Unrecoverable read error. Force an attempt to reconnect. logMessage(LOG_DEBUG_SERIAL, "ERROR, on serial port\n"); @@ -94,6 +107,11 @@ int main(int argc, char *argv[]) { } lastID = packet_buffer[PKT_DEST]; + received_packets++; + } + + if (received_packets >= PACKET_MAX) { + _keepRunning = false; } } @@ -102,18 +120,10 @@ int main(int argc, char *argv[]) { logMessage(LOG_DEBUG_SERIAL, "Ran out of storage, some ID's were not captured, please increase SLOG_MAX and recompile\n"); logMessage(LOG_DEBUG_SERIAL, "ID's found\n"); for (i=0; i <= sindex; i++) { - logMessage(LOG_DEBUG_SERIAL, "ID 0x%02hhx is %s\n",slog[i].ID, slog[i].inuse==true?"in use":"not used"); + logMessage(LOG_DEBUG_SERIAL, "ID 0x%02hhx is %s %s\n",slog[i].ID, + slog[i].inuse==true?"in use":"not used", + slog[i].inuse==false && canUse(slog[i].ID)==true?" <-- can use for Aqualinkd":""); } - /* - static serial_id_logger slog[SLOG_MAX]; - static unsigned char lastID; - static int index = 0; - if (packet_buffer[PKT_DEST] == DEV_MASTER && packet_buffer[PKT_CMD] == CMD_ACK) { - logMessage(LOG_DEBUG_SERIAL, "ID is in use 0x%02hhx\n",lastID); - } - lastID = packet_buffer[PKT_DEST]; - } - */ return 0; } \ No newline at end of file