2007-06-05 03:04:35 +00:00
|
|
|
#include "openzap.h"
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
zap_fsk_data_state_t state = {0};
|
|
|
|
int fd;
|
|
|
|
int16_t buf[160] = {0};
|
|
|
|
ssize_t len = 0;
|
|
|
|
int type, mlen;
|
2007-06-05 16:57:32 +00:00
|
|
|
char *sp;
|
|
|
|
char str[128] = "";
|
2007-06-05 03:04:35 +00:00
|
|
|
char fbuf[256];
|
|
|
|
|
|
|
|
if (argc < 2 || zap_fsk_demod_init(&state, 8000, fbuf, sizeof(fbuf))) {
|
|
|
|
printf("wtf\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((fd = open(argv[1], O_RDONLY)) < 0) {
|
|
|
|
fprintf(stderr, "cant open file %s\n", argv[1]);
|
|
|
|
exit (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
while((len = read(fd, buf, sizeof(buf))) > 0) {
|
|
|
|
if (zap_fsk_demod_feed(&state, buf, len / 2) != ZAP_SUCCESS) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-05 16:57:32 +00:00
|
|
|
while(zap_fsk_data_parse(&state, &type, &sp, &mlen) == ZAP_SUCCESS) {
|
|
|
|
zap_copy_string(str, sp, mlen+1);
|
|
|
|
*(str+mlen) = '\0';
|
|
|
|
zap_clean_string(str);
|
|
|
|
printf("TYPE %d (%s) LEN %d VAL [%s]\n", type, zap_mdmf_type2str(type), mlen, str);
|
2007-06-05 03:04:35 +00:00
|
|
|
}
|
|
|
|
|
2007-06-05 16:57:32 +00:00
|
|
|
zap_fsk_demod_destroy(&state);
|
2007-06-05 03:04:35 +00:00
|
|
|
|
|
|
|
close(fd);
|
|
|
|
}
|