Serial Port & Bluetooth
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello All,
My last question http://www.mathworks.com/matlabcentral/answers/9630-bluetooth-communication helped me a lot and I've made some progress in establishing a connection.
I've downloaded a Bluetooth driver for my USB dongle and now I can create a Serial Port for my Bluetooth connection. However, I've created only one COM port, is it possible to read and write to the same COM port?
The reason for this question, is that I'm currently not receiving anything on this COM port. I can write without errors, but I don't know how to check if it is received on my Bluetooth Device. Does anyone have any tips or ideas?
Greetings,
Hans
댓글 수: 0
채택된 답변
Chirag Gupta
2011년 7월 7일
You can read/write on the same COM port. The trick to checking whether data is being sent or received by the serial port and your device is to use some sort of serial port monitor. Googling for it, should give you plenty of hits.
The serial port monitor can confirm whether the data is being sent to the device and vice-versa. Once you can confirm data is being sent and received, you would have to then check whether its the correct data (i.e: you are sending out the exact commands that your device expects)
댓글 수: 2
추가 답변 (2개)
Iman
2013년 8월 14일
편집: Iman
2013년 8월 14일
Hi
I have this bluetooth device powered by an arduino which I can connect via COM port in a serial monitor such as putty. However I cannot do this in matlab.
I set this up as a normal com port as follows:
s = serial('COM6','BaudRate',9600,'DataBits',8,'StopBits',1,'Parity','None','FlowControl','None','ByteOrder','bigEndian','DataTerminalReady','off');
fopen(s);
I usually get an error at fopen like this:
Error using serial/fopen (line 72) Open failed: Cannot connect to the COM6 port. Possible reasons are another application is connected to the port or the port does not exist.
Error in arduino2matlab (line 13) fopen(s);
Or sometimes it states that port is not open and then lists that same port as an available port. I'm sure I've closed it in the serial monitor and nothing else should be using it. And when I use this code for hard-wire usb it works fine in matlab. I just don't understand why I cannot open the port in matlab but can in putty.
Thanks
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Web Services에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!