Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <errno.h>
- #include <stropts.h>
- #include <fcntl.h>
- #include <si4713.h>
- #include <asm/ioctl.h>
- //warning testing only...
- //some missing error handling around ;)
- int main (int argc, char *argv[]) //argc = number of arguments (including program name!), argv = list of strings
- {
- if (argc < 2) //check if argument for frequenzy is given
- {
- printf("Need frequency argument\n");
- return -EINVAL;
- }
- int fd = open("/dev/radio0", O_RDWR); //opens "file" /deve/radio with reading and writing flag (O_RDWR)
- perror ("Opening /dev/radio0:");
- if (fd < 0) //if opening of file fails:
- {
- close(fd); //close file
- return fd;
- }
- struct si4713_rnl rnl; //define structure rnl as si4713_rnl
- int rval; //variable for noise level
- sscanf(argv[1], "%d", &rnl.frequency); //writes the string to int convertet frequency argument to rnl.frequenzy (& = no pinter)
- //Missing error handling?
- rval = ioctl(fd, SI4713_IOC_MEASURE_RNL, &rnl);
- perror ("Optaining noise Level:");
- if (rval < 0)
- {
- close(fd);
- return rval;
- }
- printf("received noise level: %d\n", rval);
- close(fd);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement