用c编写一个程序,总是出错,请大家帮忙看下哪里有错误?#include #include #include #include #include int main(){int fd ;if ((fd = serialOpen ("/dev/ttyAMA0",115200)) < 0){fprintf (stderr,"Unable to open serial device:%s\n",strerror (

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 13:51:52
用c编写一个程序,总是出错,请大家帮忙看下哪里有错误?#include #include #include #include #include int main(){int fd ;if ((fd = serialOpen (
xT]OP+'3.3B2^y5vQniJ a'aJF Aȟ9 =gIszޏy?Xv+&wtqsnc-f i.;دimUnHWڹ%V-_^ӍdzZП\tFOݐ"5!=$ .L]I?jB=m{f h!!MeM@βU4q象L5dgP&@ " zRg!l&fL$&Lߕٺ]I:ogʠMB^0]k22@*15{4P#grJ1 n4;Jn1i'xA"fөxĹ#@KlJ%M…I][>ےsCViiKC]K_- e%B Ttu%N?o&:͢48Czބ%acSmy믱ZZiϽ}H{wC׼BUQ;&k

用c编写一个程序,总是出错,请大家帮忙看下哪里有错误?#include #include #include #include #include int main(){int fd ;if ((fd = serialOpen ("/dev/ttyAMA0",115200)) < 0){fprintf (stderr,"Unable to open serial device:%s\n",strerror (
用c编写一个程序,总是出错,请大家帮忙看下哪里有错误?
#include
#include
#include
#include
#include
int main()
{
int fd ;
if ((fd = serialOpen ("/dev/ttyAMA0",115200)) < 0)
{
fprintf (stderr,"Unable to open serial device:%s\n",strerror (errno)) ;
return 1 ;
}
char str[] = serialGetchar();
int len=strlen(str);
char buf[100];
int a[4];
int i = 0;
while ( str[i] = '\0' )
{
if (isdigit(str[i]))
buf[i] = str[i];
else buf[i] = ' ';
++i;
}
buf[i] = '\0';
sscanf (buf,"%d %d %d %d",&a[0],&a[1],&a[2],&a[3]);
printf ("%d %d %d %d\n",a[0],a[1],a[2],a[3]);
return 0;
}
背景是这样的,蓝牙发送一串字符给单片机,例如g90s80x70y60,我想把数字分割出来,分别付给一个变量.

用c编写一个程序,总是出错,请大家帮忙看下哪里有错误?#include #include #include #include #include int main(){int fd ;if ((fd = serialOpen ("/dev/ttyAMA0",115200)) < 0){fprintf (stderr,"Unable to open serial device:%s\n",strerror (
char str[] = serialGetchar(); //这句改成以下:
char str[128];
strcpy( str,serialGetchar() );
另:你的fd没有用到啊,是不是在serialGetchar()函数中应用?没有函数说明,不能确定