-
Notifications
You must be signed in to change notification settings - Fork 0
/
Speech.c
63 lines (50 loc) · 1.1 KB
/
Speech.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include <stdlib.h>
#include <wiringPi.h>
#include <wiringSerial.h>
#include "inputcommander.h"
// Speech
// 获取Speech信息
int SpeechGetCommand(struct InputCommander *Speech)
{ int nread = 0;
read(Speech->fd,Speech->command,sizeof(Speech->command));
if(nread == 0){
printf("usart for Speech read over time\n");
}else{
return nread;
}
}
// 初始化
int SpeechInit(struct InputCommander *Speech,char *ipAdress,char *port)
{
int fd;
if((fd = serialOpen(Speech->deviceName,9600)) == -1)
{
exit(-1);
}
Imu ->fd = fd;
return fd ;
}
// 定义imu基本信息
struct InputCommander SpeechContrl =
{
/* data */
.commandName = "Speech",
.deviceName = "/dev/ttySa4",
.command = {'\0'},
.Init = SpeechInit,
.getCommand = SpeechGetCommand,
.log = {'\0'},
.next = NULL
};
// 线程
struct InputCommander* addSpeechContrlToInputCommandLink(struct InputCommander *phead)
{
if(phead == NULL){
return &Speech;
}
else{
Speech.next = phead;
phead = &Speech;
}
}