binary mode working too
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 14 Apr 2018 02:43:21 +0000 (02:43 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 14 Apr 2018 02:43:21 +0000 (02:43 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3483 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/horus_api.c
codec2-dev/src/horus_demod.c
codec2-dev/src/horus_l2.c
codec2-dev/src/horus_l2.h

index a7440132f4ff9d285747a12b04da8764ee6dcfb6..9ebbd52d0e4870e9111e61b702c2a5eb45877553 100644 (file)
@@ -103,6 +103,7 @@ struct horus *horus_open (int mode) {
         }
         hstates->uw_len = sizeof(uw_horus_binary);
         hstates->uw_thresh = sizeof(uw_horus_binary) - 2; /* allow a few bit errors in UW detection */
+        horus_l2_init();
     }
    
     hstates->fsk = fsk_create(hstates->Fs, hstates->Rs, hstates->mFSK, 1000, 2*hstates->Rs);
@@ -258,9 +259,9 @@ int extract_horus_rtty(struct horus *hstates, char ascii_out[], int uw_loc) {
 
 
 int extract_horus_binary(struct horus *hstates, char hex_out[], int uw_loc) {
-    const int nfield = 8;                               /* 8 bit binary                   */
-    int st = uw_loc + hstates->uw_len;                  /* first bit of first char        */
-    int en = uw_loc + hstates->max_packet_len - nfield; /* last bit of max length packet  */
+    const int nfield = 8;                      /* 8 bit binary                   */
+    int st = uw_loc;                           /* first bit of first char        */
+    int en = uw_loc + hstates->max_packet_len; /* last bit of max length packet  */
 
     int      j, b, nout;
     uint8_t  rxpacket[hstates->max_packet_len];
@@ -287,9 +288,30 @@ int extract_horus_binary(struct horus *hstates, char hex_out[], int uw_loc) {
         nout++;
     }
 
+    if (hstates->verbose) {
+        fprintf(stderr, "nout: %d\nReceived Packet before decoding:\n", nout);
+        for (b=0; b<nout; b++) {
+            fprintf(stderr, "%02X", rxpacket[b]);
+        }
+        fprintf(stderr, "\n");
+    }
+    
     uint8_t payload_bytes[HORUS_BINARY_NUM_PAYLOAD_BYTES];
     horus_l2_decode_rx_packet(payload_bytes, rxpacket, HORUS_BINARY_NUM_PAYLOAD_BYTES);
 
+    /* convert to ASCII string of hex characters */
+
+    hex_out[0] = 0;
+    char hex[3];
+    for (b=0; b<HORUS_BINARY_NUM_PAYLOAD_BYTES; b++) {
+        sprintf(hex, "%02X", payload_bytes[b]);
+        strcat(hex_out, hex);
+    }
+   
+    if (hstates->verbose) {
+        fprintf(stderr, "nout: %d\nDecoded Payload bytes:\n%s", nout, hex_out);
+    }
+    
     return 1;
 }
 
index 5ff6af0add22d3860cbdc20f5fcc2fde02669cff..d7d01c5085c5c1034fa9a6b6b33dddcc3691efe6 100644 (file)
@@ -14,6 +14,8 @@
 
     $ sox ~/Desktop/horus.wav -r 48000 -t raw - | ./horus_demod -m RTTY -v - /dev/nul/
 
+    $ sox ~/Desktop/4FSK_binary_100Rb_8khzfs.wav -r 48000 -t raw - | ./horus_demod -m binary  - -
+
 \*---------------------------------------------------------------------------*/
 
 /*
@@ -167,7 +169,7 @@ int main(int argc, char *argv[]) {
     
     /* Main loop ----------------------------------------------------------------------- */
 
-    while( fread(demod_in, sizeof(short), horus_nin(hstates), fin) == horus_nin(hstates) ) {
+    while(fread(demod_in, sizeof(short), horus_nin(hstates), fin) ==  horus_nin(hstates)) {
 
         if (verbose) {
             fprintf(stderr, "read nin %d\n", horus_nin(hstates));
index 55fdc63a34465406092a4501a6695fd2074dc107..ae37d22eaa4872770810f2b129e70c4c91de0a6a 100644 (file)
@@ -109,6 +109,9 @@ int horus_l2_get_num_tx_data_bytes(int num_payload_data_bytes) {
     return num_tx_data_bytes;
 }
 
+void horus_l2_init(void) {
+    golay23_init();
+}
 
 /*
   Takes an array of payload data bytes, prepends a unique word and appends
index 86a9d76e7012f52ff522ecd9a37f2708db3eff2a..6cb42ba8403764182b0902e7112282fee00ab833 100644 (file)
 
 int horus_l2_get_num_tx_data_bytes(int num_payload_data_bytes);
 
+/* call this first */
+
+void horus_l2_init(void);
+
 /* returns number of output bytes in output_tx_data */
 
 int horus_l2_encode_tx_packet(unsigned char *output_tx_data,