필터 지우기
필터 지우기

Serial Port & Bluetooth

조회 수: 2 (최근 30일)
Hans
Hans 2011년 7월 7일
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

채택된 답변

Chirag Gupta
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
Hans
Hans 2011년 7월 7일
So this does include the Virtual Serial Port? Because my USB Bluetooth dongle is not actually a RS232 for example.
Chirag Gupta
Chirag Gupta 2011년 7월 7일
yes,virtual ports should show up as well

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Iman
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

Hans
Hans 2013년 8월 15일
Hello Iman,
Have you connected the Bluetooth device with the Bluetooth program provided by Windows?
This was my first error, after I connected it first to the computer and then opened it with Matlab, it worked just fine.
Greetings,
Hans

카테고리

Help CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by