-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add freq to lanentry #445
Add freq to lanentry #445
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ char lan_message[256]; | |
//-------------------------------------- | ||
int bc_socket_descriptor[MAXNODES]; | ||
ssize_t bc_sendto_rc; | ||
int cl_send_inhibit = 0; | ||
bool cl_send_inhibit = false; | ||
struct sockaddr_in bc_address[MAXNODES]; | ||
/* host names and UDP ports to send notifications to */ | ||
char bc_hostaddress[MAXNODES][16]; | ||
|
@@ -167,7 +167,7 @@ int lan_recv(void) { | |
errno = 0; /* clear the error */ | ||
|
||
if (lan_recv_message[1] == CLUSTERMSG) | ||
cl_send_inhibit = 1; // this node does not send cluster info | ||
cl_send_inhibit = true; // this node does not send cluster info | ||
|
||
if (lan_recv_rc > 0) | ||
recv_packets++; | ||
|
@@ -269,23 +269,22 @@ static int lan_send(char *lanbuffer) { | |
|
||
/* ----------------- send lan message ----------*/ | ||
|
||
int send_lan_message(int opcode, char *message) { | ||
void send_lan_message(int opcode, char *message) { | ||
char sendbuffer[102]; | ||
|
||
sendbuffer[0] = thisnode; | ||
sendbuffer[1] = opcode; | ||
sendbuffer[2] = '\0'; | ||
strncat(sendbuffer, message, 98); | ||
if (opcode == CLUSTERMSG) { | ||
if (cl_send_inhibit == 0) { | ||
if (!cl_send_inhibit) { | ||
strcat(sendbuffer, "\n"); | ||
lan_send(sendbuffer); | ||
} | ||
} | ||
|
||
if (opcode == LOGENTRY) { | ||
sendbuffer[82] = '\0'; | ||
|
||
strcat(sendbuffer, "\n"); | ||
lan_send(sendbuffer); | ||
} | ||
|
||
|
@@ -298,7 +297,7 @@ int send_lan_message(int opcode, char *message) { | |
lan_send(sendbuffer); | ||
} | ||
if (opcode == FREQMSG) { | ||
sendbuffer[10] = '\0'; | ||
strcat(sendbuffer, "\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is new line needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. send_freq() formats the QRG as xxxx.y with one decimal. Without the newline the decimal gets dropped. See also above. |
||
lan_send(sendbuffer); | ||
} | ||
if (opcode == INCQSONUM) { | ||
|
@@ -324,7 +323,7 @@ int send_lan_message(int opcode, char *message) { | |
lan_send(sendbuffer); | ||
} | ||
|
||
return 0; | ||
return; | ||
} | ||
|
||
/* ----------------- send talk message ----------*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ | |
|
||
pthread_mutex_t disk_mutex = PTHREAD_MUTEX_INITIALIZER; | ||
|
||
char lan_logline[81]; | ||
char lan_logline[LOGLINELEN + 1]; | ||
|
||
|
||
/* restart band timer if in wpx and qso on new band */ | ||
|
@@ -106,10 +106,10 @@ void log_to_disk(int from_lan) { | |
|
||
} else { /* qso from lan */ | ||
|
||
/* LOGENTRY contains 82 characters (node,command and logline */ | ||
g_strlcpy(lan_logline, lan_message + 2, 81); | ||
char *fill = g_strnfill(80 - strlen(lan_logline), ' '); | ||
g_strlcat(lan_logline, fill, 81); /* fill with spaces if needed */ | ||
/* LOGENTRY contains max. 89 characters (node,command and logline */ | ||
g_strlcpy(lan_logline, lan_message + 2, LOGLINELEN); | ||
char *fill = g_strnfill(LOGLINELEN - 1 - strlen(lan_logline), ' '); | ||
g_strlcat(lan_logline, fill, LOGLINELEN); /* add spaces if no frequency data */ | ||
|
||
if (cqwwm2) { /* mark as coming from other station */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about removing this dubious check and have QSOs coming from other nodes marked with an asterisk? Or even better: align the working with the man page - There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a good idea. But I would like to check first which other places needs to be changed to make it work and change that afterwards. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just reread the CQWW rules about logging the second stations contacts. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aha, thanks. Then this will need some work to sort out. |
||
if (lan_message[0] != thisnode) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sendbuffer seems to contain a correctly formatted log line. I tested it OK without adding a new line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for adding the newline is on the receiving end. Lines 137-139 in background_process.c always drop the last character of the received string. That is the normal code used to drop appended newlines from strings.
As all LAN-messages are sent as normal text strings it seems appropriate to terminate any of them with a newline. That also makes the debuglog more readable.
I think we should harmonize all LAN messages to that behavior. That would also allow us to simplify the send_lan_message() code.
At the moment (with the suggested changes) we add a newline to almost all messages. Only exception is send_time() where a space is added to the time string to avoid truncation. That should be change too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are processing our own messages, so any preprocessing is at least suspicious. Blindly dropping the last char is even worse. This is a legacy code originating from af43a4d. It must have been a quick, but incorrect fix for some unknown problem.
Logging shall cope with any message and in fact it does this OK in background_process.c:
So I see no reason adding NL on the sending side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the whole code (besides the QTCxxx messages) are ancient code (It is also in the very early 0.9.10 version from 2003). There was neither time nor need to sort it out. But let us do it now.
I do not think that it was a fix - I assume Rein had NL terminated strings in mind when writing these lines. But the whole artificial fixes of line length (lan_loglin[xx] = '\0') looks really like hot fixes, especially as all these xx values are mostly wrong.
In meantime I did some work to harmonize the LAN message format to EVERY time use of at least ONE NL (which would be dropped by the two lines in question) - see last commit. The generated messages sometimes contains two NL (even without my change). So that mess should really be sorted out.
See my second message as comment to your plan below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the removal of last char be made more relaxed using
g_strchomp()
instead?