各位大哥高手:
小弟想在sbc2410开发板通过蓝牙串口和手机串口发送数据,调试不成功。
蓝牙协议栈及驱动都已经安装成功。配置如下:
hciconfig hci0 up
sdptool add --channel=1 SP
rfcomm bindi 0 手机MAC
mknod /dev/rfcomm0 c 216 0
hcitool cc 手机MAC
错误情况:
发送几次之后控制台打出USB disconnect on device,然后又马上注册上了.
不知道是不是驱动不稳定的原因?板子上的内核版本是2.4.18.打的bluez.org
网站上download的patch.蓝牙协议栈版本2.17
驱动就是内核代码中自带的.没有任何修改.
程序如下:
int main(int argc, char **argv)
{
int fd;
int i = 1;
int nwrite;
int nwrite1;
unsigned char * buff[2*1024];
char *dev ="/dev/rfcomm0";
char* file = "./configure";
FILE * fp;
fd = OpenDev(dev);
if (fd>0)
set_speed(fd,19200);
else
{
printf("Can't Open Serial Port!\n");
exit(0);
}
if (set_Parity(fd,8,1,'N')== FALSE)
{
printf("Set Parity Error\n");
exit(1);
}
if((fp = fopen(file,"rb")) == NULL)
{
printf("Failed to open the mfs file\n");
exit(1);
}
while(!feof(fp))
{
while(nwrite = fread(buff, 1, 2*1024, fp))
{
if(nwrite < 0)
{
printf("\nnwrite < 0\n");
break;
}
nwrite = write(fd,buff,nwrite);
if(nwrite > 0)
{
printf("\ntimes %d ,Len %d\n",i, nwrite);
//printf("\nfile is %s\n", file);
}
i++;
}
}
fclose(fp);
close(fd);
}
|