How to change tty behavior on bluetooth socket

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to change tty behavior on bluetooth socket

1,450件の閲覧回数
patsandt
Contributor III

I'm running Linux on the iMX6Q. I have code that accepts a Bluetooth connection on a socket. When I did this on the command line, I could have used stty (stty -F /dev/rfcomm0 raw) to change the default TTY behavior from converting all my LFs to CRLFs. However, now I'm running from code, and /dev/rfcomm0 does not exist. The closest "device" I can find is /dev/bus/usb/001/002, but I cannot run stty on that device. When I send a line-feed in the data stream, the tty interface seems to change it to \r\n. The result is that my length field is incorrect. The protocol does not include \r, so it is not sufficient for me to just bump the length. 

I've looked at the supported ioctl controls and found nothing. Open to any and all suggestions.

ラベル(3)
タグ(2)
0 件の賞賛
3 返答(返信)

1,183件の閲覧回数
patsandt
Contributor III

Unfortunately, I have a socket, but not a dev. That is, "/dev/rfcomm0" does not appear as a device. "/dev/ttyUSB0" does not appear as a device. There are 100 other /dev/tty? devices, but I've not been able to determine which a am (if any).

Still open to suggestions.

0 件の賞賛

1,183件の閲覧回数
patsandt
Contributor III

I've added the following code after the accept call:

struct rfcomm_dev_req req;

memset(&req,0,sizeof(req));

req.dev_id = 0; //?? might depend on other connections, but I have none at this time

req.flags = (1 << RFCOMM_REUSE_DLC) | (1 << RFCOMM_RELEASE_ONHUP);

bacpy(&req.src, &loc_addr.rc_bdaddr);

bacpy(&req.dst, &rem_addr.rc_bdaddr);

req.channel = rem_addr.rc_channel;

int dev = ioctl(clientSock, RFCOMMCREATEDEV, &req);

std::string devname = "/dev/rfcomm";

devname += std::to_string(dev);

I'm assuming I'm on the right track because it DID create a /dev/rfcomm entry.

0 件の賞賛

1,183件の閲覧回数
igorpadykov
NXP Employee
NXP Employee

Hi Pat

one can try with tty interface raw mode

Configuring Linux’s serial port to raw mode – Alan C. Assis 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛