修改cmdline(略)
语音识别模块二次开发
识别口令后串口发送的信息
识别操作语音发送的信息(开所有灯,开红灯……)
核心思想
取指->译码->执行
为什么不让串口直接发送与继电器驱动对应的指针???
语音识别模块不好发送16进制格式的指针!!!!
一丶通过read串口读取指令(ascll形式)
二丶将读取到的指令转化为继电器驱动规定的输入指令格式
三丶将转化后的指令write到内核驱动
语音模块控制程序(删的只剩框架)
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <wiringPi.h>
#include <wiringSerial.h>
int decoding(char *code)//将串口指令转化为16进制指令
{
return -1;
}
void speakControl()
{
int fd_Serial = serialOpen("/dev/ttyAMA0",9600);
if(fd_Serial == -1){
printf("open serial fail\n");
exit(-1);
}
int fd_Relay = open("/dev/relay",O_RDWR);
if(fd_Relay == -1){
perror("open");
exit(-1);
}
int cmd = 0x01;
char code[4] = {0};
while(1){
memset(code,'\0',4);
read(fd_Serial,code,4);
cmd = decoding(code);
if(cmd == -1){
printf("cmd not exist\n");
continue;
}
//十六进制指令处理
if(cmd == 0x0f){
}else{
}
}
}
int main(int argc,char **argv)
{
if(-1 == wiringPiSetup())
{
printf("set up error\n");
exit(-1);
}
speakControl();
return 0;
}