Fixed incorrect length while sending callsigns

pull/4/head
Mark Qvist 2015-01-18 17:54:28 +01:00
rodzic 5edb62cf8d
commit b858936e3e
2 zmienionych plików z 8 dodań i 5 usunięć

Wyświetl plik

@ -10,7 +10,7 @@
#define countof(a) sizeof(a)/sizeof(a[0])
#define MIN(a,b) ({ typeof(a) _a = (a); typeof(b) _b = (b); ((typeof(_a))((_a < _b) ? _a : _b)); })
#define DECODE_CALL(buf, addr) for (unsigned i = 0; i < sizeof((addr))-1; i++) { char c = (*(buf)++ >> 1); (addr)[i] = (c == ' ') ? '\x0' : c; }
#define DECODE_CALL(buf, addr) for (unsigned i = 0; i < sizeof((addr))-CALL_OVERSPACE; i++) { char c = (*(buf)++ >> 1); (addr)[i] = (c == ' ') ? '\x0' : c; }
#define AX25_SET_REPEATED(msg, idx, val) do { if (val) { (msg)->rpt_flags |= _BV(idx); } else { (msg)->rpt_flags &= ~_BV(idx) ; } } while(0)
extern int LibAPRS_vref;
@ -116,7 +116,7 @@ void ax25_sendRaw(AX25Ctx *ctx, void *_buf, size_t len) {
}
static void ax25_sendCall(AX25Ctx *ctx, const AX25Call *addr, bool last){
unsigned len = MIN(sizeof(addr->call-1), strlen(addr->call));
unsigned len = MIN((sizeof(addr->call) - CALL_OVERSPACE), strlen(addr->call));
for (unsigned i = 0; i < len; i++) {
uint8_t c = addr->call[i];
@ -124,8 +124,8 @@ static void ax25_sendCall(AX25Ctx *ctx, const AX25Call *addr, bool last){
ax25_putchar(ctx, c << 1);
}
if (len < sizeof(addr->call-1)) {
for (unsigned i = 0; i < sizeof(addr->call-1) - len; i++) {
if (len < (sizeof(addr->call) - CALL_OVERSPACE)) {
for (unsigned i = 0; i < (sizeof(addr->call) - CALL_OVERSPACE) - len; i++) {
ax25_putchar(ctx, ' ' << 1);
}
}

Wyświetl plik

@ -38,8 +38,11 @@ typedef struct AX25Ctx {
#define AX25_MAX_RPT 8
#define AX25_REPEATED(msg, n) ((msg)->rpt_flags & BV(n))
#define CALL_OVERSPACE 1
typedef struct AX25Call {
char call[7];
char call[6+CALL_OVERSPACE];
//char STRING_TERMINATION = 0;
uint8_t ssid;
} AX25Call;