POCSAG: Allow all 128 ASCII characters to be transmitted using pointed brackets

This commit is contained in:
Andreas Eversberg 2024-04-28 17:47:55 +02:00
parent a6bf66ee83
commit 1f55ad659b
6 changed files with 69 additions and 10 deletions

View File

@ -3,10 +3,12 @@
"active_layer": 0,
"active_layer_preset": "All Layers",
"auto_track_width": false,
"hidden_netclasses": [],
"hidden_nets": [],
"high_contrast_mode": 0,
"net_color_mode": 1,
"opacity": {
"images": 0.6,
"pads": 1.0,
"tracks": 1.0,
"vias": 1.0,

View File

@ -1,5 +1,6 @@
{
"board": {
"3dviewports": [],
"design_settings": {
"defaults": {
"board_outline_line_width": 0.049999999999999996,
@ -137,7 +138,8 @@
"zones_allow_external_fillets": false,
"zones_use_no_outline": true
},
"layer_presets": []
"layer_presets": [],
"viewports": []
},
"boards": [],
"cvpcb": {
@ -359,7 +361,7 @@
"net_settings": {
"classes": [
{
"bus_width": 12.0,
"bus_width": 12,
"clearance": 0.2,
"diff_pair_gap": 0.25,
"diff_pair_via_gap": 0.25,
@ -373,13 +375,15 @@
"track_width": 0.25,
"via_diameter": 0.8,
"via_drill": 0.4,
"wire_width": 6.0
"wire_width": 6
}
],
"meta": {
"version": 2
"version": 3
},
"net_colors": null
"net_colors": null,
"netclass_assignments": null,
"netclass_patterns": []
},
"pcbnew": {
"last_paths": {

View File

@ -38,7 +38,7 @@
static const char numeric[16] = "0123456789RU -][";
static const char hex[16] = "0123456789abcdef";
static const char *ctrl_char[33] = {
static const char *ctrl_char[32] = {
"<NUL>",
"<SOH>",
"<STX>",
@ -71,9 +71,10 @@ static const char *ctrl_char[33] = {
"<GS>",
"<RS>",
"<US>",
"<DEL>",
};
static const char *del_char = "<DEL>";
const char *print_message(const char *message, int message_length)
{
static char message_print[1024];
@ -85,7 +86,7 @@ const char *print_message(const char *message, int message_length)
if (message[i] >= 0 && message[i] <= 31)
c = ctrl_char[(int)message[i]];
else if (message[i] == 127)
c = ctrl_char[(int)message[32]];
c = del_char;
else {
message_print[ii++] = message[i];
continue;
@ -101,6 +102,50 @@ const char *print_message(const char *message, int message_length)
return message_print;
}
int scan_message(const char *message_input, int message_input_length, char *message_output, int message_output_length)
{
int i, ii, j, clen;
/* i is input counter, ii is output counter */
for (i = 0, ii = 0; i < message_input_length; ii++) {
if (ii == message_output_length)
break;
if (message_input[i] == '<') {
/* maybe a control character ? */
for (j = 0; j < 32; j++) {
clen = strlen(ctrl_char[j]);
/* skip, if control sequence would not fit into the input buffer */
if (clen <= message_input_length - i && !memcmp(message_input + i, ctrl_char[j], clen)) {
/* found control sequence, so break the loop */
break;
}
}
if (j < 32) {
/* if loop was not completed, use the found character */
message_output[ii] = j;
i += clen;
} else {
clen = strlen(del_char);
/* skip, if control sequence would not fit into the input buffer */
if (clen <= i - message_input_length && !memcmp(message_input + i, del_char, clen)) {
/* found control sequence, copy DEL character */
message_output[ii] = 127;
i += clen;
} else {
/* found no control sequence, copy '<' character */
message_output[ii] = '<';
i++;
}
}
} else {
/* no control character */
message_output[ii] = message_input[i];
i++;
}
}
return ii;
}
static uint32_t pocsag_crc(uint32_t word)
{

View File

@ -1,5 +1,6 @@
const char *print_message(const char *message, int message_length);
int scan_message(const char *message_input, int message_input_length, char *message_output, int message_output_length);
int64_t get_codeword(pocsag_t *pocsag);
void put_codeword(pocsag_t *pocsag, uint32_t word, int8_t slot, int8_t subslot);

View File

@ -94,6 +94,14 @@ void print_help(const char *arg0)
printf("File: %s\n", MSG_SEND);
printf(" Write \"<ric>,0,message\" to it to send a numerical message.\n");
printf(" Write \"<ric>,3,message\" to it to send an alphanumerical message.\n");
printf(" alphanumeric messages may contain any character except LF and CR.\n");
printf(" Any control character can be sent by using pointed brackets:\n");
printf(" '<NUL>' '<SOH>' '<STX>' '<ETX>' '<EOT>' '<ENQ>' '<ACK>' '<BEL>'\n");
printf(" '<BS>' '<HT>' '<LF>' '<VT>' '<FF>' '<CR>' '<SO>' '<SI>'\n");
printf(" '<DLE> '<DC1>' '<DC2' '<DC3>' '<DC4>' '<NAK>' '<SYN>' '<ETB>'\n");
printf(" '<CAN>' '<EM>' '<SUB>' '<ESC>' '<FS>' '<GS>' '<RS>' '<US>'\n");
printf(" '<DEL> Example: Hello,<LF><CR>World!'\n");
printf("File: %s\n", MSG_RECEIVED);
printf(" Read from it to see received messages.\n");
main_mobile_print_station_id();

View File

@ -441,8 +441,7 @@ inval:
if (text_length) {
text++;
text_length--;
memcpy(message, text, text_length);
message_length = text_length;
message_length = scan_message(text, text_length, message, sizeof(message));
}
ric = atoi(ric_string);