示例#1
0
文件: rs41sg.c 项目: CWCorrea/RS
int main(int argc, char *argv[]) {

    FILE *fp;
    char bitbuf[8];
    int bit_count = 0,
        byte_count = FRAMESTART,
        header_found = 0,
        byte, i;
    int bit, len;

    ++argv;
    while ((*argv) && (!wavloaded)) {
        if      ( (strcmp(*argv, "-v") == 0) || (strcmp(*argv, "--verbose") == 0) ) {
            option_verbose = 1;
        }
        else if ( (strcmp(*argv, "-r") == 0) || (strcmp(*argv, "--raw") == 0) ) {
            option_raw = 1;
        }
        else {
            if ( !(fp = fopen(*argv, "rb")) ) {
                fprintf(stderr, "%s konnte nicht geoeffnet werden\n", *argv);
                return -1;
            }
            else wavloaded = 1;
        }
        ++argv;
    }
    if (!wavloaded) {
        fprintf(stderr, "rs41sg [options] <rs41_audio.wav>\n");
        fprintf(stderr, "  options:\n");
        fprintf(stderr, "       -v, --verbose\n");
        fprintf(stderr, "       -r, --raw\n");
        return -1;
    }


    i = read_wav_header(fp);
    if (i) {
        fclose(fp);
        return -1;
    }


    while (!read_bits_fsk(fp, &bit, &len)) {

        if (len == 0) { // reset_frame();
            if (byte_count > FRAME_LEN-20) print_frame(byte_count);
            bit_count = 0;
            byte_count = FRAMESTART;
            header_found = 0;
            inc_bufpos();
            buf[bufpos] = 'x';
            continue;   // ...
        }

        for (i = 0; i < len; i++) {

            inc_bufpos();
            buf[bufpos] = 0x30 + bit;  // Ascii

            if (!header_found) {
                if (compare() >= HEADLEN) header_found = 1;
            }
            else {
                bitbuf[bit_count] = bit;
                bit_count++;
            
                if (bit_count == 8) {
                    bit_count = 0;
                    byte = bits2byte(bitbuf);
                    frame[byte_count] = byte;
                    byte_count++;
                    if (byte_count == FRAME_LEN) {
                        byte_count = FRAMESTART;
                        header_found = 0;
                        print_frame(FRAME_LEN);
                    }
                }
            }

        }

    }
    fclose(fp);

    return 0;
}
示例#2
0
文件: dfm06.c 项目: CWCorrea/RS
int main(int argc, char **argv) {

    FILE *fp;
    char *fpname;
    int pos, i, j, bit, len;
    int header_found = 0;

#ifdef CYGWIN
    _setmode(fileno(stdin), _O_BINARY);  // _setmode(_fileno(stdin), _O_BINARY);
    setbuf(stdout, NULL);
#endif

    fpname = argv[0];
    ++argv;
    while ((*argv) && (!wavloaded)) {
        if      ( (strcmp(*argv, "-h") == 0) || (strcmp(*argv, "--help") == 0) ) {
            fprintf(stderr, "%s [options] audio.wav\n", fpname);
            fprintf(stderr, "  options:\n");
            fprintf(stderr, "       -v, --verbose\n");
            fprintf(stderr, "       -r, --raw\n");
            fprintf(stderr, "       -i, --invert\n");
            return 0;
        }
        else if ( (strcmp(*argv, "-v") == 0) || (strcmp(*argv, "--verbose") == 0) ) {
            option_verbose = 1;
        }
        else if ( (strcmp(*argv, "-r") == 0) || (strcmp(*argv, "--raw") == 0) ) {
            option_raw = 1;
        }
        else if ( (strcmp(*argv, "-R") == 0) || (strcmp(*argv, "--RAW") == 0) ) {
            option_raw = 2;
        }
        else if ( (strcmp(*argv, "-i") == 0) || (strcmp(*argv, "--invert") == 0) ) {
            option_inv = 0x1;
        }
        else if ( (strcmp(*argv, "--auto") == 0) ) {
            option_auto = 1;
        }
        else {
            fp = fopen(*argv, "rb");
            if (fp == NULL) {
                fprintf(stderr, "%s konnte nicht geoeffnet werden\n", *argv);
                return -1;
            }
            wavloaded = 1;
        }
        ++argv;
    }
    if (!wavloaded) fp = stdin;


    i = read_wav_header(fp);
    if (i) {
        fclose(fp);
        return -1;
    }


    gpx.sonde_id = -1;
    for (i = 0; i < 9; i++) {
        for (j = 0; j < 13; j++) dat_str[i][j] = ' ';
    }


    pos = FRAMESTART;

    while (!read_bits_fsk(fp, &bit, &len)) {

        if (len == 0) { // reset_frame();
            if (pos > RAWBITFRAME_LEN-10) { // Problem wegen Interleaving
                print_frame();//byte_count
                header_found = 0;
                pos = FRAMESTART;
            }
            //inc_bufpos();
            //buf[bufpos] = 'x';
            continue;   // ...
        }

        for (i = 0; i < len; i++) {

            inc_bufpos();
            buf[bufpos] = 0x30 + bit;  // Ascii

            if (!header_found) {
                header_found = compare2();
                if (header_found < 0) option_inv ^= 0x1;
            }
            else {
                frame_rawbits[pos] = 0x30 + bit;  // Ascii
                pos++;
            
                if (pos == RAWBITFRAME_LEN) {
                    print_frame();//FRAME_LEN
                    header_found = 0;
                    pos = FRAMESTART;
                }
            }
        }
    }

    fclose(fp);

    return 0;
}
示例#3
0
文件: meisei_ecc.c 项目: rs1729/RS
int main(int argc, char **argv) {

    FILE *fp;
    char *fpname;
    int i, j;
    int bit_count = 0,
        header_found = 0,
        bit, len;

    int counter;
    ui32_t val;
    ui32_t dat2;
    int lat, lat1, lat2,
        lon, lon1, lon2,
        alt, alt1, alt2;
    int latdeg,londeg;
    double latmin, lonmin;
    ui32_t t1, t2, ms, min, std, tt, mm, jj;


#ifdef CYGWIN
    _setmode(fileno(stdin), _O_BINARY);  // _setmode(_fileno(stdin), _O_BINARY);
#endif
    setbuf(stdout, NULL);


    fpname = argv[0];
    ++argv;
    while ((*argv) && (!wavloaded)) {
        if      ( (strcmp(*argv, "-h") == 0) || (strcmp(*argv, "--help") == 0) ) {
        help_out:
            fprintf(stderr, "%s <-n> [options] audio.wav\n", fpname);
            fprintf(stderr, "  n=1,2\n");
            fprintf(stderr, "  options:\n");
            //fprintf(stderr, "       -v, --verbose\n");
            fprintf(stderr, "       -r, --raw\n");
            return 0;
        }
        else if ( (strcmp(*argv, "-r") == 0) || (strcmp(*argv, "--raw") == 0) ) {
            option_raw = 1;
        }
        else if   (strcmp(*argv, "--res") == 0) { option_res = 1; }
        else if ( (strcmp(*argv, "-i") == 0) || (strcmp(*argv, "--invert") == 0) ) {
            option_inv = 1;  // nicht noetig
        }
        else if ( (strcmp(*argv, "-2") == 0) ) {
            option2 = 1;
        }
        else if ( (strcmp(*argv, "-1") == 0) ) {
            option1 = 1;
        }
        else if   (strcmp(*argv, "--ecc") == 0) { option_ecc = 1; }
        else if ( (strcmp(*argv, "-v") == 0) ) {
            option_verbose = 1;
        }
        else {
            if ((option1 == 1  && option2 == 1) || (!option_raw && option1 == 0  && option2 == 0)) goto help_out;
            fp = fopen(*argv, "rb");
            if (fp == NULL) {
                fprintf(stderr, "%s konnte nicht geoeffnet werden\n", *argv);
                return -1;
            }
            wavloaded = 1;
        }
        ++argv;
    }
    if (!wavloaded) fp = stdin;


    i = read_wav_header(fp);
    if (i) {
        fclose(fp);
        return -1;
    }

    if (option_ecc) {
        rs_init_BCH64();
    }


    bufpos = 0;
    bit_count = 0;

    while (!read_bits_fsk(fp, &bit, &len)) {

        if (len == 0) { // reset_frame();
/*
            if (byte_count > FRAME_LEN-20) {
                print_frame(byte_count);
                bit_count = 0;
                byte_count = FRAMESTART;
                header_found = 0;
            }
*/
            //inc_bufpos();
            //buf[bufpos] = 'x';
            continue;   // ...
        }

        for (i = 0; i < len; i++) {

            inc_bufpos();
            buf[bufpos] = 0x30 + bit;  // Ascii

            if (!header_found) {
                header_found = compare_subheader();
                if (header_found) {
                    bit_count = 0;
                    for (j = 0; j < HEADLEN; j++) {
                        if (header_found % 2 == 1) frame_bits[j] = header0x049DCEbits[j] - 0x30;
                        else                       frame_bits[j] = header0xFB6230bits[j] - 0x30;
                    }
                }
            }
            else {
                frame_rawbits[bit_count] = 0x30 + bit;
                bit_count++;

                if (bit_count >= RAWBITFRAME_LEN/4-RAWHEADLEN) {  // 600-48
                    frame_rawbits[bit_count] = '\0';

                    biphi_s(frame_rawbits, frame_bits+HEADLEN);

                    if (option_ecc) {
                        for (block = 0; block < 6; block++) {

                            // prepare block-codeword
                            for (j =  0; j < 46; j++) cw[45-j] = frame_bits[HEADLEN + block*46+j];
                            for (j = 46; j < 63; j++) cw[j] = 0;

                            errors = rs_decode_bch_gf2t2(cw, err_pos, err_val);

                            // check parity,padding
                            if (errors >= 0) {
                                check_err = 0;
                                for (i = 46; i < 63; i++) { if (cw[i] != 0) check_err = 0x1; }
                                par = 1;
                                for (i = 13; i < 13+16; i++) par ^= cw[i];
                                if (cw[12] != par) check_err |= 0x100;
                                par = 1;
                                for (i = 30; i < 30+16; i++) par ^= cw[i];
                                if (cw[29] != par) check_err |= 0x10;
                                if (check_err) errors = -3;
                            }
                            if (errors >= 0) {
                                for (j = 0; j < 46; j++) frame_bits[HEADLEN + block*46+j] = cw[45-j];
                            }

                            if (errors < 0) block_err[block] = 0xE;
                            else            block_err[block] = errors;

                        }
                    }

                    if (!option2 && !option_raw) {

                        if (header_found % 2 == 1) {
                            val = bits2val(frame_bits+HEADLEN, 16);
                            counter = val & 0xFFFF;
                            if (counter % 2 == 0) printf("\n");
                            //printf("[0x%04X = %d] ", counter, counter);
                            printf("[%d] ", counter);

                            if (counter % 2 == 1) {
                                t2 = bits2val(frame_bits+HEADLEN+5*46  , 8);  // LSB
                                t1 = bits2val(frame_bits+HEADLEN+5*46+8, 8);
                                ms = (t1 << 8) | t2;
                                std = bits2val(frame_bits+HEADLEN+5*46+17, 8);
                                min = bits2val(frame_bits+HEADLEN+5*46+25, 8);
                                printf("  ");
                                printf("%02d:%02d:%06.3f ", std, min, (double)ms/1000.0);
                                printf("  ");

                                //printf("\n");
                            }
                        }

                        if (header_found % 2 == 0) {
                            val = bits2val(frame_bits+HEADLEN, 16);
                            //printf("%04x ", val & 0xFFFF);
                            if ((counter % 2 == 0))  { //  (val & 0xFFFF) > 0)  {// == 0x8080
                                //offset=24+16+1;

                                lat1 = bits2val(frame_bits+HEADLEN+17, 16);
                                lat2 = bits2val(frame_bits+HEADLEN+46, 16);
                                lon1 = bits2val(frame_bits+HEADLEN+46+17, 16);
                                lon2 = bits2val(frame_bits+HEADLEN+46+46, 16);
                                alt1 = bits2val(frame_bits+HEADLEN+46+46+17, 16);
                                alt2 = bits2val(frame_bits+HEADLEN+46+46+46, 16);

                                lat = (lat1 << 16) | lat2;
                                lon = (lon1 << 16) | lon2;
                                alt = (alt1 << 16) | alt2;
                                //printf("%08X %08X %08X :  ", lat, lon, alt);
                                printf("  ");
                                printf("%.6f  %.6f  %.2f", (double)lat/1e7, (double)lon/1e7, (double)alt/1e2);
                                printf("  ");

                                jj = bits2val(frame_bits+HEADLEN+5*46+ 8, 8) + 0x0700;
                                mm = bits2val(frame_bits+HEADLEN+5*46+17, 8);
                                tt = bits2val(frame_bits+HEADLEN+5*46+25, 8);
                                printf("  ");
                                printf("%4d-%02d-%02d ", jj, mm, tt);
                                printf("  ");

                                //printf("\n");
                            }
                        }

                    }
                    else if (option2 && !option_raw) {

                        if (header_found % 2 == 1) {
                            val = bits2val(frame_bits+HEADLEN, 16);
                            counter = val & 0xFFFF;
                            if (counter % 2 == 0) printf("\n");
                            //printf("[0x%04X = %d] ", counter, counter);
                            printf("[%d] ", counter);

                            if (counter % 2 == 0) {
                                t1 = bits2val(frame_bits+HEADLEN+5*46  , 8);  // MSB
                                t2 = bits2val(frame_bits+HEADLEN+5*46+8, 8);
                                ms = (t1 << 8) | t2;
                                std = bits2val(frame_bits+HEADLEN+5*46+17, 8);
                                min = bits2val(frame_bits+HEADLEN+5*46+25, 8);
                                printf("  ");
                                printf("%02d:%02d:%06.3f ", std, min, (double)ms/1000.0);
                                printf("  ");
                            }
                        }

                        if (header_found % 2 == 0) {
                            val = bits2val(frame_bits+HEADLEN, 16);
                            //printf("%04x ", val & 0xFFFF);
                            if ((counter % 2 == 0))  { //  (val & 0xFFFF) > 0)  {// == 0x2390
                                //offset=24+16+1;

                                dat2 = bits2val(frame_bits+HEADLEN, 16);
                                printf("%05u (?%02d-%02d-%02d) ", dat2, dat2/1000,(dat2/10)%100, (dat2%10)+10);

                                lat1 = bits2val(frame_bits+HEADLEN+17, 16);
                                lat2 = bits2val(frame_bits+HEADLEN+46, 16);
                                lon1 = bits2val(frame_bits+HEADLEN+46+17, 16);
                                lon2 = bits2val(frame_bits+HEADLEN+46+46, 16);
                                alt1 = bits2val(frame_bits+HEADLEN+46+46+17, 16);
                                alt2 = bits2val(frame_bits+HEADLEN+46+46+46,  8);

                                lat = (lat1 << 16) | lat2;
                                lon = (lon1 << 16) | lon2;
                                alt = (alt1 <<  8) | alt2;
                                latdeg = (int)lat / 1e6;
                                latmin = (double)(lat/1e6-latdeg)*100/60.0;
                                londeg = (int)lon / 1e6;
                                lonmin = (double)(lon/1e6-londeg)*100/60.0;
                                //printf("%08X %08X %08X :  ", lat, lon, alt);
                                printf("  ");
                                printf("%.6f  %.6f  %.2f", (double)latdeg+latmin, (double)londeg+lonmin, (double)alt/1e2);
                                printf("  ");
                            }
                            //else { printf("\n"); }
                        }

                    }
                    else { // raw

                        val = bits2val(frame_bits, HEADLEN);
                        printf("%06X ", val & 0xFFFFFF);
                        printf("  ");
                        for (i = 0; i < 6; i++) {

                            val = bits2val(frame_bits+HEADLEN+46*i   , 16);
                            printf("%04X ", val & 0xFFFF);

                            val = bits2val(frame_bits+HEADLEN+46*i+17, 16);
                            printf("%04X ", val & 0xFFFF);

                            val = bits2val(frame_bits+HEADLEN+46*i+34, 12);
                            //printf("%03X ", val & 0xFFF);
                            //printf(" ");
                        }
                        printf("\n");
                    }

                    bit_count = 0;
                    header_found = 0;

                    if (option_ecc && option_verbose) {
                        printf("#");
                        for (block = 0; block < 6; block++) printf("%X", block_err[block]);
                        printf("#  ");
                    }
                }
            }
        }
    }

    printf("\n");

    fclose(fp);

    return 0;
}
示例#4
0
文件: rs_main41.c 项目: rs1729/RS
int main(int argc, char *argv[]) {

    FILE *fp = NULL;
    char *fpname = NULL;
    char *bitbuf = NULL;
    int bit_count = 0,
        header_found = 0,
        frmlen = 0;
    int i, bit, len;
    int err = 0;


    setbuf(stdout, NULL);

    fpname = argv[0];
    ++argv;
    while ((*argv) && (!wavloaded)) {
        if      ( (strcmp(*argv, "-h") == 0) || (strcmp(*argv, "--help") == 0) ) {
            fprintf(stderr, "%s [options] audio.wav\n", fpname);
            fprintf(stderr, "  options:\n");
            fprintf(stderr, "       -v, -vx, -vv  (info, aux, info/conf)\n");
            fprintf(stderr, "       -r, --raw\n");
            fprintf(stderr, "       -i, --invert\n");
            fprintf(stderr, "       --crc        (check CRC)\n");
            fprintf(stderr, "       --std        (std framelen)\n");
            return 0;
        }
        else if ( (strcmp(*argv, "-v") == 0) || (strcmp(*argv, "--verbose") == 0) ) {
            option_verbose |= 0x1;
        }
        else if   (strcmp(*argv, "-vx") == 0) { option_verbose |= 0x2; }
        else if   (strcmp(*argv, "-vv") == 0) { option_verbose |= 0x3; }
        else if   (strcmp(*argv, "--crc") == 0) { option_crc = 1; }
        else if ( (strcmp(*argv, "-r") == 0) || (strcmp(*argv, "--raw") == 0) ) {
            option_raw = 1;
        }
        else if ( (strcmp(*argv, "-i") == 0) || (strcmp(*argv, "--invert") == 0) ) {
            option_inv = 1;
        }
        else if   (strcmp(*argv, "--std" ) == 0) { frmlen = 320; }  // NDATA_LEN
        else if   (strcmp(*argv, "--std2") == 0) { frmlen = 518; }  // FRAME_LEN
        else if   (strcmp(*argv, "--sat") == 0) { option_sat = 1; option_verbose |= 0x100; }
        else {
            fp = fopen(*argv, "rb");
            if (fp == NULL) {
                fprintf(stderr, "%s konnte nicht geoeffnet werden\n", *argv);
                return -1;
            }
            wavloaded = 1;
        }
        ++argv;
    }
    if (!wavloaded) fp = stdin;


    rs_data_t rs41data = {{0}};
    rs_data_t *rs_data = &rs41data;
    rs_data->input = 8;
    err = init_rs41data(rs_data);
    if (err) goto error_tag;
    frame = rs_data->frame_bytes;
    if (frmlen == 0) frmlen = rs_data->frame_len;

    err = read_wav_header(fp, rs_data);
    if (err) goto error_tag;

    bitbuf = calloc(rs_data->bits, 1);
    if (bitbuf == NULL)  {
        err = -1;
        goto error_tag;
    }

    rs_data->pos = rs_data->frame_start;

    while (!read_bits_fsk(fp, &bit, &len, option_inv)) {

        if (len == 0) { // reset_frame();
            if (rs_data->pos > rs_data->pos_min) {
                print_frame(rs_data);
                bit_count = 0;
                rs_data->pos = rs_data->frame_start;
                header_found = 0;
            }
            //inc_bufpos();
            //buf[bufpos] = 'x';
            continue;   // ...
        }

        for (i = 0; i < len; i++) {

            inc_bufpos(rs_data);
            rs_data->buf[rs_data->bufpos] = 0x30 + bit;  // Ascii

            if (!header_found) {
                if (compare(rs_data) >= rs_data->header_len) header_found = 1;
            }
            else {

                if (rs_data->input < 8) {
                    rs_data->frame_rawbits[rs_data->bits*rs_data->pos + bit_count] = 0x30 + bit;
                }

                bitbuf[bit_count] = bit;
                bit_count++;

                if (bit_count == rs_data->bits) {
                    bit_count = 0;
                    if (rs_data->input == 8) {
                        frame[rs_data->pos] = rs_data->bits2byte(rs_data, bitbuf);
                    }
                    rs_data->pos++;
                    if (rs_data->pos == frmlen) {
                        print_frame(rs_data);
                        rs_data->pos = rs_data->frame_start;
                        header_found = 0;
                    }
                }
            }

        }
    }

    free(bitbuf);
    bitbuf = NULL;

error_tag:
    fclose(fp);
    free_rs41data(rs_data);

    return err;
}
示例#5
0
文件: dfm06web.c 项目: DE8MSH/RS
int main(int argc, char **argv) {

    FILE *fp;
    char *fpname;
    char *lathome;
    char *lonhome;
    int pos, i, j, bit, len;
    int header_found = 0;

#ifdef CYGWIN
    _setmode(fileno(stdin), _O_BINARY);  // _setmode(_fileno(stdin), _O_BINARY);
    setbuf(stdout, NULL);
#endif
	
    fpname = argv[0];
    // 53.045390 8.893852
    lathome = argv[3];
    lonhome = argv[4];

/////////////////// MINI WEBSERVER BY http://blog.manula.org/2011/05/writing-simple-web-server-in-c.html
    int create_socket, new_socket;    
    socklen_t addrlen;    
    int bufsize = 1024;    
    char *buffer = malloc(bufsize);    
    struct sockaddr_in address;    
//////////////////////    

    ++argv;
    while ((*argv) && (!wavloaded)) {
        if      ( (strcmp(*argv, "-h") == 0) || (strcmp(*argv, "--help") == 0) ) {
            fprintf(stderr, "%s [options] audio.wav\n", fpname);
            fprintf(stderr, "  options:\n");
            fprintf(stderr, "       -v, --verbose\n");
            fprintf(stderr, "       -r, --raw\n");
            fprintf(stderr, "       -i, --invert\n");
            return 0;
        }
        else if ( (strcmp(*argv, "-v") == 0) || (strcmp(*argv, "--verbose") == 0) ) {
            option_verbose = 1;
        }
        else if ( (strcmp(*argv, "-r") == 0) || (strcmp(*argv, "--raw") == 0) ) {
            option_raw = 1;
        }
        else if ( (strcmp(*argv, "-R") == 0) || (strcmp(*argv, "--RAW") == 0) ) {
            option_raw = 2;
        }
        else if ( (strcmp(*argv, "-i") == 0) || (strcmp(*argv, "--invert") == 0) ) {
            option_inv = 0x1;
        }
        else if ( (strcmp(*argv, "--auto") == 0) ) {
            option_auto = 1;
        }
        else {
            fp = fopen(*argv, "rb");
            if (fp == NULL) {
                fprintf(stderr, "%s konnte nicht geoeffnet werden\n", *argv);
                return -1;
            }
            wavloaded = 1;
        }
        ++argv;
    }
    if (!wavloaded) fp = stdin;

/////////////////// MINI WEBSERVER BY http://blog.manula.org/2011/05/writing-simple-web-server-in-c.html
    if ((create_socket = socket(AF_INET, SOCK_STREAM, 0)) > 0){    
       printf("The socket was created\n");
    }
    
    address.sin_family = AF_INET;    
    address.sin_addr.s_addr = INADDR_ANY;    
    address.sin_port = htons(8081);    
    
    if (bind(create_socket, (struct sockaddr *) &address, sizeof(address)) == 0){    
       printf("Binding Socket\n");
    }
    
    if (listen(create_socket, 10) < 0) {    
       perror("server: listen");    
       exit(1);    
    }    
    
    if ((new_socket = accept(create_socket, (struct sockaddr *) &address, &addrlen)) < 0) {    
       perror("server: accept");    
       exit(1);    
    }    
    
    if (new_socket > 0){    
       printf("Connected to client\n");
    }
//////////////////////    

    i = read_wav_header(fp);
    if (i) {
        fclose(fp);
        close(new_socket);     
        close(create_socket); 
        return -1;
    }


    gpx.sonde_id = -1;
    for (i = 0; i < 9; i++) {
        for (j = 0; j < 13; j++) dat_str[i][j] = ' ';
    }


    pos = FRAMESTART;

    while (!read_bits_fsk(fp, &bit, &len)) {

        if (len == 0) { // reset_frame();
            if (pos > RAWBITFRAME_LEN-10) { // Problem wegen Interleaving
/////////////////// MINI WEBSERVER BY http://blog.manula.org/2011/05/writing-simple-web-server-in-c.html
                write(new_socket, "hello world\n", 12);    
//////////////////////    
                print_frame();//byte_count
                header_found = 0;
                pos = FRAMESTART;
            }
            //inc_bufpos();
            //buf[bufpos] = 'x';
            continue;   // ...
        }

        for (i = 0; i < len; i++) {

            inc_bufpos();
            buf[bufpos] = 0x30 + bit;  // Ascii

            if (!header_found) {
                header_found = compare2();
                if (header_found < 0) option_inv ^= 0x1;
            }
            else {
                frame_rawbits[pos] = 0x30 + bit;  // Ascii
                pos++;
            
                if (pos == RAWBITFRAME_LEN) {
                    print_frame();//FRAME_LEN
                    header_found = 0;
                    pos = FRAMESTART;
                }
            }
        }
    }

    fclose(fp);
    close(new_socket);     
    close(create_socket);    

    return 0;
}