Serial Port & Bluetooth

6 次查看(过去 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

Community Treasure Hunt

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

Start Hunting!

Translated by