第30节:buzzer蜂鸣器
1、编写编译运行测试
root@ubuntu:/home/linuxsystemcode/buzzer# cat buzzer.c
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#define BUZZER_C 2
int main(int argc,char *argv[]){
char *buzzer_ctl = "/dev/buzzer_ctl";
if(atoi(argv[1])>= buzzer_c){
printf("argv[1] is 0 or 1\n");
exit(1);
}
if((fd = open(buzzer_ctl,O_RDWR|O_NOCTTY|O_NDELAY))<0){
pr
1、编写编译运行测试
root@ubuntu:/home/linuxsystemcode/buzzer# cat buzzer.c
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#define BUZZER_C 2
int main(int argc,char *argv[]){
char *buzzer_ctl = "/dev/buzzer_ctl";
int fd,ret,buzzer_c;
buzzer_c = BUZZER_C;if(atoi(argv[1])>= buzzer_c){
printf("argv[1] is 0 or 1\n");
exit(1);
}
if((fd = open(buzzer_ctl,O_RDWR|O_NOCTTY|O_NDELAY))<0){
pr