Skip to content

Commit

Permalink
Minor fix to ignore 0x0a0d at end of data
Browse files Browse the repository at this point in the history
- 0x0a0d is sent along with the last archive data packet, so have to
  ignore it when checking the length of the data packet
- Minor modification of the verbose sending command message
  • Loading branch information
bytesnz committed Sep 8, 2017
1 parent 62ec779 commit e721078
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "dhandler.h"
#include "byte.h"

#define VERSION "1.3.0"
#define VERSION "1.3.1"

/* local Data */
static char szttyDevice[255]; /* Serial device string */
Expand Down Expand Up @@ -720,7 +720,7 @@ int runCommand(char* command, int commandLength, int expectedLength, char* dataL
}

if(bVerbose) {
printf("Getting %s data set...\n", dataLabel);
printf("Sending %s...\n", dataLabel);
}

if (bDebug) {
Expand Down Expand Up @@ -775,15 +775,25 @@ int runCommand(char* command, int commandLength, int expectedLength, char* dataL

if(bVerbose) {
printf("Got %d of %d characters...", nCnt, totalLength);
}

// Check for 0x0a0d at end
if (nCnt == totalLength + 2) {
if (szSerBuffer[totalLength] == 0x0a
&& szSerBuffer[totalLength + 1] == 0x0d) {
printf("Good\n");
}
} else {
if(nCnt != totalLength)
printf("Bad\n");
else
printf("Good\n");
}
if(nCnt != totalLength) {
fprintf(stderr, "vproweather: Didn't get all data. Try changing delay parameter.\n");
return -1;
exit(2);

if(nCnt != totalLength) {
fprintf(stderr, "vproweather: Didn't get all data. Try changing delay parameter.\n");
return -1;
exit(2);
}
}
if (expectingCrc) {
if((nCnt = CheckCRC(expectedLength,
Expand Down

0 comments on commit e721078

Please sign in to comment.