-
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
Conversation
Frequency is correctly stored, but see the comments. |
@@ -284,8 +284,7 @@ int send_lan_message(int opcode, char *message) { | |||
} | |||
|
|||
if (opcode == LOGENTRY) { | |||
sendbuffer[82] = '\0'; | |||
|
|||
strcat(sendbuffer, "\n"); |
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:
148 fputs(lan_message, fp);
149 fputs("\n", fp);
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?
@@ -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 comment
The 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 comment
The 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.
src/log_to_disk.c
Outdated
@@ -46,7 +46,7 @@ | |||
|
|||
pthread_mutex_t disk_mutex = PTHREAD_MUTEX_INITIALIZER; | |||
|
|||
char lan_logline[81]; | |||
char lan_logline[89]; |
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.
LOGLINELEN + 1 ? or would LOGLINELEN suffice?
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.
Hmm, comments say LOGLINELEN (87) includes all logline information including linefeed. That would mean LOGLINELEN+1 for buffer.
But as the newline is already stripped away one character less would be enough.
Anyway we should use symbol instead of the hard coded number.
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.
Err, LOGLINELEN is defined as 88.
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, log lines in the log file are 88 chars long including the NL. Internally it's the buffer length is the same as there is a NUL instead of NL.
src/log_to_disk.c
Outdated
/* LOGENTRY contains 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); /* fill with spaces if needed */ |
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.
I believe that this would cut away the NL added in the lan code. It is correct, as NL is appended anyway in store_qso()
.
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.
As discussed above the newline is already cut off here.
/* LOGENTRY contains 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); /* fill with spaces if needed */ | ||
|
||
if (cqwwm2) { /* mark as coming from other station */ |
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.
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 -
CQWW_M2
Put the node ID into the logline (just after the QSO number) to
support Multi/2 operation where the station logging the QSO must
be in the Cabrillo file. This can also be used for M/1 and M/M,
to enable post-contest analysis of the nodes.
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Just reread the CQWW rules about logging the second stations contacts.
<The MULTIPLIER SIGNAL will be designated with a “1” in the transmitter column of the Cabrillo log. >
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.
Aha, thanks. Then this will need some work to sort out.
Thanks for review. See answers inline. |
How about this plan?
I can help with 2) and 3). |
See the last commit to see a more developed state after harmonizing the sent code. But, let us discus your plan.
Ok, rework of the commits can be made easily. I would make a new PR for it. (Maybe not before friday).
Or maybe better in the code, e.g. in lancode.h. I think the message format is not relevant for normal user.
Fine by me. |
Thanks for the updates. I still see no need for the NL, but can live with it. You can use this PR, no separate one is needed IMO. Re 2): lancode.h is also a perfect place to document the messages. |
- send with terminating newline - drop size restrictions in lan_send_message() - change definition of msg-codes into readable ascii characters
1294d1e
to
99f24f4
Compare
That should be step 1. Using g_strchomp is a good idea. |
Thanks for the update. |
Fix handling of missing QRG for log entry sent via LAN.