aboutsummaryrefslogtreecommitdiff
path: root/src/fsk_get_test_bits.c
diff options
context:
space:
mode:
authordrowe67 <[email protected]>2023-07-20 08:59:48 +0930
committerGitHub <[email protected]>2023-07-20 08:59:48 +0930
commit06d4c11e699b0351765f10398abb4f663a984f36 (patch)
tree33e22af0814c5b6c3d676f096ae8c2ac8a3ed9f0 /src/fsk_get_test_bits.c
parent6588e77f38bdebd7adffe091b22e7760d95d0ccb (diff)
parent4d6c143c0abec15e1d6ed1fd95d36f80e6cb7df8 (diff)
Merge pull request #3 from drowe67/dr-cleanup21.2.0
Cleanup Part 2
Diffstat (limited to 'src/fsk_get_test_bits.c')
-rw-r--r--src/fsk_get_test_bits.c121
1 files changed, 61 insertions, 60 deletions
diff --git a/src/fsk_get_test_bits.c b/src/fsk_get_test_bits.c
index 937ccf0..e8246d3 100644
--- a/src/fsk_get_test_bits.c
+++ b/src/fsk_get_test_bits.c
@@ -8,7 +8,6 @@
\*---------------------------------------------------------------------------*/
-
/*
Copyright (C) 2016 David Rowe
@@ -26,72 +25,74 @@
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
#include "fsk.h"
-#define TEST_FRAME_SIZE 100 /* arbitrary choice, repeats after this
- many bits, sets frame size for rx
- processing */
-
-int main(int argc,char *argv[]){
- int bitcnt, framecnt;
- int framesize = TEST_FRAME_SIZE;
- int i;
- FILE *fout;
- uint8_t *bitbuf;
-
- if(argc < 3){
- fprintf(stderr,"usage: %s OutputBitsOnePerByte numBits [framesize]\n",argv[0]);
- exit(1);
- }
+#define TEST_FRAME_SIZE \
+ 100 /* arbitrary choice, repeats after this \
+ many bits, sets frame size for rx \
+ processing */
- if (argc == 4){
- framesize = atoi(argv[3]);
- fprintf(stderr, "Using custom frame size of %d bits\n", framesize);
- }
-
- /* Extract parameters */
- bitcnt = atoi(argv[2]);
- framecnt = bitcnt/framesize;
- if (framecnt == 0) {
- fprintf(stderr,"Need a minimum of %d bits\n", framesize);
- exit(1);
- }
+int main(int argc, char *argv[]) {
+ int bitcnt, framecnt;
+ int framesize = TEST_FRAME_SIZE;
+ int i;
+ FILE *fout;
+ uint8_t *bitbuf;
- if(strcmp(argv[1],"-")==0){
- fout = stdout;
- }else{
- fout = fopen(argv[1],"w");
- }
-
- if(fout==NULL){
- fprintf(stderr,"Couldn't open output file: %s\n", argv[1]);
- exit(1);
- }
-
- /* allocate buffers for processing */
- bitbuf = (uint8_t*)malloc(sizeof(uint8_t)*framesize);
-
- /* Generate buffer of test frame bits from known seed */
- srand(158324);
- for(i=0; i<framesize; i++){
- bitbuf[i] = rand()&0x1;
- }
-
- /* Output test frames */
- srand(158324);
- for(i=0; i<framecnt; i++){
- fwrite(bitbuf,sizeof(uint8_t),framesize,fout);
- if(fout == stdout){
- fflush(fout);
- }
+ if (argc < 3) {
+ fprintf(stderr, "usage: %s OutputBitsOnePerByte numBits [framesize]\n",
+ argv[0]);
+ exit(1);
+ }
+
+ if (argc == 4) {
+ framesize = atoi(argv[3]);
+ fprintf(stderr, "Using custom frame size of %d bits\n", framesize);
+ }
+
+ /* Extract parameters */
+ bitcnt = atoi(argv[2]);
+ framecnt = bitcnt / framesize;
+ if (framecnt == 0) {
+ fprintf(stderr, "Need a minimum of %d bits\n", framesize);
+ exit(1);
+ }
+
+ if (strcmp(argv[1], "-") == 0) {
+ fout = stdout;
+ } else {
+ fout = fopen(argv[1], "w");
+ }
+
+ if (fout == NULL) {
+ fprintf(stderr, "Couldn't open output file: %s\n", argv[1]);
+ exit(1);
+ }
+
+ /* allocate buffers for processing */
+ bitbuf = (uint8_t *)malloc(sizeof(uint8_t) * framesize);
+
+ /* Generate buffer of test frame bits from known seed */
+ srand(158324);
+ for (i = 0; i < framesize; i++) {
+ bitbuf[i] = rand() & 0x1;
+ }
+
+ /* Output test frames */
+ srand(158324);
+ for (i = 0; i < framecnt; i++) {
+ fwrite(bitbuf, sizeof(uint8_t), framesize, fout);
+ if (fout == stdout) {
+ fflush(fout);
}
-
- free(bitbuf);
- fclose(fout);
+ }
+
+ free(bitbuf);
+ fclose(fout);
- return 0;
+ return 0;
}