How to I connect a raw serial terminal to a bluetooth connection?
I'm trying to connect to a Totalstation that doesn't offer bluetooth drivers. As I am doing this for purely diagnostic reasons, I'd like to see the raw output from the established serial connection.
What do I have to do to pipe all output from a bluetooth connection to a terminal?
bluetooth
add a comment |
I'm trying to connect to a Totalstation that doesn't offer bluetooth drivers. As I am doing this for purely diagnostic reasons, I'd like to see the raw output from the established serial connection.
What do I have to do to pipe all output from a bluetooth connection to a terminal?
bluetooth
Are you doing Bluetooth->Serial, Serial->Bluetooth, or two-way?
– hexafraction
Jan 29 '13 at 0:14
Totalstation Bluetooth<->Ubuntu Bluetooth. Given that the totalstation has the standard serial configuration over USB, I suspect it is establishing a serial connection over Bluetooth. Of course, I could be completely wrong, at which point the answer that I'm wrong and the bluetooth uses XYZ is completely permissible.
– Brian Ballsun-Stanton
Jan 29 '13 at 0:18
In terms of the two-way proof, I have managed to establish a blank serial connection via "screen" that causes an error beep on the device when I hit a key on the keyboard. So I suspect that I'm half-way there, I just don't know which half.
– Brian Ballsun-Stanton
Jan 29 '13 at 0:19
Can you draw up a quick diagram? I can't understand whether it's serial over or bluetooth over serial, as well as who's passing on the data to where. Just do it in GIMP or something and upload it here
– hexafraction
Jan 29 '13 at 0:20
add a comment |
I'm trying to connect to a Totalstation that doesn't offer bluetooth drivers. As I am doing this for purely diagnostic reasons, I'd like to see the raw output from the established serial connection.
What do I have to do to pipe all output from a bluetooth connection to a terminal?
bluetooth
I'm trying to connect to a Totalstation that doesn't offer bluetooth drivers. As I am doing this for purely diagnostic reasons, I'd like to see the raw output from the established serial connection.
What do I have to do to pipe all output from a bluetooth connection to a terminal?
bluetooth
bluetooth
edited Mar 7 '14 at 2:54
Braiam
52.4k20138223
52.4k20138223
asked Jan 29 '13 at 0:05
Brian Ballsun-StantonBrian Ballsun-Stanton
2121315
2121315
Are you doing Bluetooth->Serial, Serial->Bluetooth, or two-way?
– hexafraction
Jan 29 '13 at 0:14
Totalstation Bluetooth<->Ubuntu Bluetooth. Given that the totalstation has the standard serial configuration over USB, I suspect it is establishing a serial connection over Bluetooth. Of course, I could be completely wrong, at which point the answer that I'm wrong and the bluetooth uses XYZ is completely permissible.
– Brian Ballsun-Stanton
Jan 29 '13 at 0:18
In terms of the two-way proof, I have managed to establish a blank serial connection via "screen" that causes an error beep on the device when I hit a key on the keyboard. So I suspect that I'm half-way there, I just don't know which half.
– Brian Ballsun-Stanton
Jan 29 '13 at 0:19
Can you draw up a quick diagram? I can't understand whether it's serial over or bluetooth over serial, as well as who's passing on the data to where. Just do it in GIMP or something and upload it here
– hexafraction
Jan 29 '13 at 0:20
add a comment |
Are you doing Bluetooth->Serial, Serial->Bluetooth, or two-way?
– hexafraction
Jan 29 '13 at 0:14
Totalstation Bluetooth<->Ubuntu Bluetooth. Given that the totalstation has the standard serial configuration over USB, I suspect it is establishing a serial connection over Bluetooth. Of course, I could be completely wrong, at which point the answer that I'm wrong and the bluetooth uses XYZ is completely permissible.
– Brian Ballsun-Stanton
Jan 29 '13 at 0:18
In terms of the two-way proof, I have managed to establish a blank serial connection via "screen" that causes an error beep on the device when I hit a key on the keyboard. So I suspect that I'm half-way there, I just don't know which half.
– Brian Ballsun-Stanton
Jan 29 '13 at 0:19
Can you draw up a quick diagram? I can't understand whether it's serial over or bluetooth over serial, as well as who's passing on the data to where. Just do it in GIMP or something and upload it here
– hexafraction
Jan 29 '13 at 0:20
Are you doing Bluetooth->Serial, Serial->Bluetooth, or two-way?
– hexafraction
Jan 29 '13 at 0:14
Are you doing Bluetooth->Serial, Serial->Bluetooth, or two-way?
– hexafraction
Jan 29 '13 at 0:14
Totalstation Bluetooth<->Ubuntu Bluetooth. Given that the totalstation has the standard serial configuration over USB, I suspect it is establishing a serial connection over Bluetooth. Of course, I could be completely wrong, at which point the answer that I'm wrong and the bluetooth uses XYZ is completely permissible.
– Brian Ballsun-Stanton
Jan 29 '13 at 0:18
Totalstation Bluetooth<->Ubuntu Bluetooth. Given that the totalstation has the standard serial configuration over USB, I suspect it is establishing a serial connection over Bluetooth. Of course, I could be completely wrong, at which point the answer that I'm wrong and the bluetooth uses XYZ is completely permissible.
– Brian Ballsun-Stanton
Jan 29 '13 at 0:18
In terms of the two-way proof, I have managed to establish a blank serial connection via "screen" that causes an error beep on the device when I hit a key on the keyboard. So I suspect that I'm half-way there, I just don't know which half.
– Brian Ballsun-Stanton
Jan 29 '13 at 0:19
In terms of the two-way proof, I have managed to establish a blank serial connection via "screen" that causes an error beep on the device when I hit a key on the keyboard. So I suspect that I'm half-way there, I just don't know which half.
– Brian Ballsun-Stanton
Jan 29 '13 at 0:19
Can you draw up a quick diagram? I can't understand whether it's serial over or bluetooth over serial, as well as who's passing on the data to where. Just do it in GIMP or something and upload it here
– hexafraction
Jan 29 '13 at 0:20
Can you draw up a quick diagram? I can't understand whether it's serial over or bluetooth over serial, as well as who's passing on the data to where. Just do it in GIMP or something and upload it here
– hexafraction
Jan 29 '13 at 0:20
add a comment |
3 Answers
3
active
oldest
votes
As an addition to Brian's answer. Screen didnt work for me, immediately displaying [screen is terminating]
So I found this miniterm python script. Usage is similar:
sudo miniterm.py /dev/rfcomm0
add a comment |
1) Use hcitool scan
to find the Mac address of the device.
The device should be set to slave mode with a known pin. If you don't use a known pin, ubuntu makes one up and you generally won't have time to enter it in the clunky menus of your measuring tool.
2) I'm not entirely sure this is necessary, but in the bluetooth gui menu, pair the device.
3) in /etc/bluetooth/rfcomm.conf
rfcomm0 {
bind no;
device 00:07:80:44:4F:37;
channel 1;
comment "Serial Port";
}
The "bind no" is important, otherwise it will try to autmatically bind, which presents all sorts of problems for actually accessing the device (as it's quite picky about when its associated)
4) sudo rfcomm connect 0
If you have errors, restart the bluetooth service.
5) screen /dev/rfcomm0
For actual serial commands transmitted this way, contact your vendor and beg.
3
I get "Missing dev parameter" when I try to run "rfcomm connect 0"
– someonewithpc
Mar 27 '16 at 16:43
Did you edit your conf file correctly?
– Brian Ballsun-Stanton
Mar 28 '16 at 0:58
5
Try sudo rfcomm connect rfcomm0 00:07:80:44:4F:37
– elopio
Jul 4 '16 at 5:52
@elopia's oneliner very simple. It worked for me
– ptetteh227
Mar 31 '18 at 2:27
add a comment |
Here is my way to proceed to connect to a HC-05 bluetooth device plugged on my arduino. It does not need to write a file like in Brian's answer, but the idea is similar. I've tested it with a baud 9600 rate setup on the HC-05 device.
First step : pair the device and provide the PIN
I tried to setup from GUI the pairing, but it wasn't working. Here is the command line way to proceed that worked for me. First, let us pair the device from command line. Run :
sudo bluetoothctl
Be sure that the bluetooth device is started :
# power on
We now start the agent that will "remember the pin" for rfcomm
:
# agent on
Now we enable the scan mode to find our device and be able to pair it :
# scan on
After a few seconds the MAC of your device should appear. We will denote it as after. Then, you just need to pair the device like this :
# pair <MAC>
You will be asked to type a PIN, by default it's 1234
on my HC-05 device. You can note that it's possible that you device connect then disconnect with a message like that :
[CHG] Device 20:16:10:24:29:77 UUIDs: 00001101-0000-1000-8000-00805f9b34fb
[CHG] Device 20:16:10:24:29:77 ServicesResolved: yes
[CHG] Device 20:16:10:24:29:77 Paired: yes
Pairing successful
[CHG] Device 20:16:10:24:29:77 ServicesResolved: no
[CHG] Device 20:16:10:24:29:77 Connected: no
but it's not a problem. You do not need to connect, so you can now quit bluetoothctl
by typing Ctrl + D
.
Provide a usable file /dev/rfcomm0
Firstly, be sure that you didn't run any rfcomm command before. Indeed, even if you close with Ctrl+C
the program, it still run in background.
sudo killall rfcomm
Now, you can run
sudo rfcomm connect /dev/rfcomm0 20:16:10:24:29:77 1 &
Note that if you try to write on the input of rfcom, nothing happened. You need to use another program.
Third and last step : write into the /dev/rfcomm0
There are several ways to write on the file, but note that all ways to proceed involve root. I describe here several programs that can do that (so that you can choose depending on your need or on what is installed on your system for example). If you forget to run the program as root, you may have an error :
stty: /dev/rfcomm0: Device or resource busy
First option : connect using screen
Screen is a very powerfull tool. You can install it (it's always usefull anymore) by using :
sudo apt-get install screen
and then run
sudo screen /dev/rfcomm0
If you forget to run it as root, you will get an error like Aleksander got :
[screen is terminating]
To quit it, type "Ctrl A + :exit"
Second option : connect using minicom
Install it
sudo apt-get install minicom
and then run
sudo minicom -D /dev/rfcomm0
If you forget to run it as root, you will have an error like
minicom: cannot open /dev/rfcomm0: Device or resource busy
To quit it, type "Ctrl + A X".
Third option : python script miniterm
Download this script, and run :
chmod +x miniterm.py
sudo ./miniterm.py /dev/rfcomm0
Write directly into the file
Firstly run the following command (9600 is the baud rate) :
sudo stty -F /dev/rfcomm0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
Now you can write in this file like in a classic file :
sudo su -c "echo 'message' > /dev/rfcomm0"
and in theory read from it using
sudo tail -f /dev/rfcomm0
But I don't know read does not work, if any of you have an idea...
/def/rfcomm0
should be/dev/rfcomm0
– stewSquared
Feb 21 at 6:10
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f248817%2fhow-to-i-connect-a-raw-serial-terminal-to-a-bluetooth-connection%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
As an addition to Brian's answer. Screen didnt work for me, immediately displaying [screen is terminating]
So I found this miniterm python script. Usage is similar:
sudo miniterm.py /dev/rfcomm0
add a comment |
As an addition to Brian's answer. Screen didnt work for me, immediately displaying [screen is terminating]
So I found this miniterm python script. Usage is similar:
sudo miniterm.py /dev/rfcomm0
add a comment |
As an addition to Brian's answer. Screen didnt work for me, immediately displaying [screen is terminating]
So I found this miniterm python script. Usage is similar:
sudo miniterm.py /dev/rfcomm0
As an addition to Brian's answer. Screen didnt work for me, immediately displaying [screen is terminating]
So I found this miniterm python script. Usage is similar:
sudo miniterm.py /dev/rfcomm0
answered Jun 5 '14 at 20:50
Aleksander BelovAleksander Belov
26623
26623
add a comment |
add a comment |
1) Use hcitool scan
to find the Mac address of the device.
The device should be set to slave mode with a known pin. If you don't use a known pin, ubuntu makes one up and you generally won't have time to enter it in the clunky menus of your measuring tool.
2) I'm not entirely sure this is necessary, but in the bluetooth gui menu, pair the device.
3) in /etc/bluetooth/rfcomm.conf
rfcomm0 {
bind no;
device 00:07:80:44:4F:37;
channel 1;
comment "Serial Port";
}
The "bind no" is important, otherwise it will try to autmatically bind, which presents all sorts of problems for actually accessing the device (as it's quite picky about when its associated)
4) sudo rfcomm connect 0
If you have errors, restart the bluetooth service.
5) screen /dev/rfcomm0
For actual serial commands transmitted this way, contact your vendor and beg.
3
I get "Missing dev parameter" when I try to run "rfcomm connect 0"
– someonewithpc
Mar 27 '16 at 16:43
Did you edit your conf file correctly?
– Brian Ballsun-Stanton
Mar 28 '16 at 0:58
5
Try sudo rfcomm connect rfcomm0 00:07:80:44:4F:37
– elopio
Jul 4 '16 at 5:52
@elopia's oneliner very simple. It worked for me
– ptetteh227
Mar 31 '18 at 2:27
add a comment |
1) Use hcitool scan
to find the Mac address of the device.
The device should be set to slave mode with a known pin. If you don't use a known pin, ubuntu makes one up and you generally won't have time to enter it in the clunky menus of your measuring tool.
2) I'm not entirely sure this is necessary, but in the bluetooth gui menu, pair the device.
3) in /etc/bluetooth/rfcomm.conf
rfcomm0 {
bind no;
device 00:07:80:44:4F:37;
channel 1;
comment "Serial Port";
}
The "bind no" is important, otherwise it will try to autmatically bind, which presents all sorts of problems for actually accessing the device (as it's quite picky about when its associated)
4) sudo rfcomm connect 0
If you have errors, restart the bluetooth service.
5) screen /dev/rfcomm0
For actual serial commands transmitted this way, contact your vendor and beg.
3
I get "Missing dev parameter" when I try to run "rfcomm connect 0"
– someonewithpc
Mar 27 '16 at 16:43
Did you edit your conf file correctly?
– Brian Ballsun-Stanton
Mar 28 '16 at 0:58
5
Try sudo rfcomm connect rfcomm0 00:07:80:44:4F:37
– elopio
Jul 4 '16 at 5:52
@elopia's oneliner very simple. It worked for me
– ptetteh227
Mar 31 '18 at 2:27
add a comment |
1) Use hcitool scan
to find the Mac address of the device.
The device should be set to slave mode with a known pin. If you don't use a known pin, ubuntu makes one up and you generally won't have time to enter it in the clunky menus of your measuring tool.
2) I'm not entirely sure this is necessary, but in the bluetooth gui menu, pair the device.
3) in /etc/bluetooth/rfcomm.conf
rfcomm0 {
bind no;
device 00:07:80:44:4F:37;
channel 1;
comment "Serial Port";
}
The "bind no" is important, otherwise it will try to autmatically bind, which presents all sorts of problems for actually accessing the device (as it's quite picky about when its associated)
4) sudo rfcomm connect 0
If you have errors, restart the bluetooth service.
5) screen /dev/rfcomm0
For actual serial commands transmitted this way, contact your vendor and beg.
1) Use hcitool scan
to find the Mac address of the device.
The device should be set to slave mode with a known pin. If you don't use a known pin, ubuntu makes one up and you generally won't have time to enter it in the clunky menus of your measuring tool.
2) I'm not entirely sure this is necessary, but in the bluetooth gui menu, pair the device.
3) in /etc/bluetooth/rfcomm.conf
rfcomm0 {
bind no;
device 00:07:80:44:4F:37;
channel 1;
comment "Serial Port";
}
The "bind no" is important, otherwise it will try to autmatically bind, which presents all sorts of problems for actually accessing the device (as it's quite picky about when its associated)
4) sudo rfcomm connect 0
If you have errors, restart the bluetooth service.
5) screen /dev/rfcomm0
For actual serial commands transmitted this way, contact your vendor and beg.
answered Feb 7 '13 at 3:44
Brian Ballsun-StantonBrian Ballsun-Stanton
2121315
2121315
3
I get "Missing dev parameter" when I try to run "rfcomm connect 0"
– someonewithpc
Mar 27 '16 at 16:43
Did you edit your conf file correctly?
– Brian Ballsun-Stanton
Mar 28 '16 at 0:58
5
Try sudo rfcomm connect rfcomm0 00:07:80:44:4F:37
– elopio
Jul 4 '16 at 5:52
@elopia's oneliner very simple. It worked for me
– ptetteh227
Mar 31 '18 at 2:27
add a comment |
3
I get "Missing dev parameter" when I try to run "rfcomm connect 0"
– someonewithpc
Mar 27 '16 at 16:43
Did you edit your conf file correctly?
– Brian Ballsun-Stanton
Mar 28 '16 at 0:58
5
Try sudo rfcomm connect rfcomm0 00:07:80:44:4F:37
– elopio
Jul 4 '16 at 5:52
@elopia's oneliner very simple. It worked for me
– ptetteh227
Mar 31 '18 at 2:27
3
3
I get "Missing dev parameter" when I try to run "rfcomm connect 0"
– someonewithpc
Mar 27 '16 at 16:43
I get "Missing dev parameter" when I try to run "rfcomm connect 0"
– someonewithpc
Mar 27 '16 at 16:43
Did you edit your conf file correctly?
– Brian Ballsun-Stanton
Mar 28 '16 at 0:58
Did you edit your conf file correctly?
– Brian Ballsun-Stanton
Mar 28 '16 at 0:58
5
5
Try sudo rfcomm connect rfcomm0 00:07:80:44:4F:37
– elopio
Jul 4 '16 at 5:52
Try sudo rfcomm connect rfcomm0 00:07:80:44:4F:37
– elopio
Jul 4 '16 at 5:52
@elopia's oneliner very simple. It worked for me
– ptetteh227
Mar 31 '18 at 2:27
@elopia's oneliner very simple. It worked for me
– ptetteh227
Mar 31 '18 at 2:27
add a comment |
Here is my way to proceed to connect to a HC-05 bluetooth device plugged on my arduino. It does not need to write a file like in Brian's answer, but the idea is similar. I've tested it with a baud 9600 rate setup on the HC-05 device.
First step : pair the device and provide the PIN
I tried to setup from GUI the pairing, but it wasn't working. Here is the command line way to proceed that worked for me. First, let us pair the device from command line. Run :
sudo bluetoothctl
Be sure that the bluetooth device is started :
# power on
We now start the agent that will "remember the pin" for rfcomm
:
# agent on
Now we enable the scan mode to find our device and be able to pair it :
# scan on
After a few seconds the MAC of your device should appear. We will denote it as after. Then, you just need to pair the device like this :
# pair <MAC>
You will be asked to type a PIN, by default it's 1234
on my HC-05 device. You can note that it's possible that you device connect then disconnect with a message like that :
[CHG] Device 20:16:10:24:29:77 UUIDs: 00001101-0000-1000-8000-00805f9b34fb
[CHG] Device 20:16:10:24:29:77 ServicesResolved: yes
[CHG] Device 20:16:10:24:29:77 Paired: yes
Pairing successful
[CHG] Device 20:16:10:24:29:77 ServicesResolved: no
[CHG] Device 20:16:10:24:29:77 Connected: no
but it's not a problem. You do not need to connect, so you can now quit bluetoothctl
by typing Ctrl + D
.
Provide a usable file /dev/rfcomm0
Firstly, be sure that you didn't run any rfcomm command before. Indeed, even if you close with Ctrl+C
the program, it still run in background.
sudo killall rfcomm
Now, you can run
sudo rfcomm connect /dev/rfcomm0 20:16:10:24:29:77 1 &
Note that if you try to write on the input of rfcom, nothing happened. You need to use another program.
Third and last step : write into the /dev/rfcomm0
There are several ways to write on the file, but note that all ways to proceed involve root. I describe here several programs that can do that (so that you can choose depending on your need or on what is installed on your system for example). If you forget to run the program as root, you may have an error :
stty: /dev/rfcomm0: Device or resource busy
First option : connect using screen
Screen is a very powerfull tool. You can install it (it's always usefull anymore) by using :
sudo apt-get install screen
and then run
sudo screen /dev/rfcomm0
If you forget to run it as root, you will get an error like Aleksander got :
[screen is terminating]
To quit it, type "Ctrl A + :exit"
Second option : connect using minicom
Install it
sudo apt-get install minicom
and then run
sudo minicom -D /dev/rfcomm0
If you forget to run it as root, you will have an error like
minicom: cannot open /dev/rfcomm0: Device or resource busy
To quit it, type "Ctrl + A X".
Third option : python script miniterm
Download this script, and run :
chmod +x miniterm.py
sudo ./miniterm.py /dev/rfcomm0
Write directly into the file
Firstly run the following command (9600 is the baud rate) :
sudo stty -F /dev/rfcomm0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
Now you can write in this file like in a classic file :
sudo su -c "echo 'message' > /dev/rfcomm0"
and in theory read from it using
sudo tail -f /dev/rfcomm0
But I don't know read does not work, if any of you have an idea...
/def/rfcomm0
should be/dev/rfcomm0
– stewSquared
Feb 21 at 6:10
add a comment |
Here is my way to proceed to connect to a HC-05 bluetooth device plugged on my arduino. It does not need to write a file like in Brian's answer, but the idea is similar. I've tested it with a baud 9600 rate setup on the HC-05 device.
First step : pair the device and provide the PIN
I tried to setup from GUI the pairing, but it wasn't working. Here is the command line way to proceed that worked for me. First, let us pair the device from command line. Run :
sudo bluetoothctl
Be sure that the bluetooth device is started :
# power on
We now start the agent that will "remember the pin" for rfcomm
:
# agent on
Now we enable the scan mode to find our device and be able to pair it :
# scan on
After a few seconds the MAC of your device should appear. We will denote it as after. Then, you just need to pair the device like this :
# pair <MAC>
You will be asked to type a PIN, by default it's 1234
on my HC-05 device. You can note that it's possible that you device connect then disconnect with a message like that :
[CHG] Device 20:16:10:24:29:77 UUIDs: 00001101-0000-1000-8000-00805f9b34fb
[CHG] Device 20:16:10:24:29:77 ServicesResolved: yes
[CHG] Device 20:16:10:24:29:77 Paired: yes
Pairing successful
[CHG] Device 20:16:10:24:29:77 ServicesResolved: no
[CHG] Device 20:16:10:24:29:77 Connected: no
but it's not a problem. You do not need to connect, so you can now quit bluetoothctl
by typing Ctrl + D
.
Provide a usable file /dev/rfcomm0
Firstly, be sure that you didn't run any rfcomm command before. Indeed, even if you close with Ctrl+C
the program, it still run in background.
sudo killall rfcomm
Now, you can run
sudo rfcomm connect /dev/rfcomm0 20:16:10:24:29:77 1 &
Note that if you try to write on the input of rfcom, nothing happened. You need to use another program.
Third and last step : write into the /dev/rfcomm0
There are several ways to write on the file, but note that all ways to proceed involve root. I describe here several programs that can do that (so that you can choose depending on your need or on what is installed on your system for example). If you forget to run the program as root, you may have an error :
stty: /dev/rfcomm0: Device or resource busy
First option : connect using screen
Screen is a very powerfull tool. You can install it (it's always usefull anymore) by using :
sudo apt-get install screen
and then run
sudo screen /dev/rfcomm0
If you forget to run it as root, you will get an error like Aleksander got :
[screen is terminating]
To quit it, type "Ctrl A + :exit"
Second option : connect using minicom
Install it
sudo apt-get install minicom
and then run
sudo minicom -D /dev/rfcomm0
If you forget to run it as root, you will have an error like
minicom: cannot open /dev/rfcomm0: Device or resource busy
To quit it, type "Ctrl + A X".
Third option : python script miniterm
Download this script, and run :
chmod +x miniterm.py
sudo ./miniterm.py /dev/rfcomm0
Write directly into the file
Firstly run the following command (9600 is the baud rate) :
sudo stty -F /dev/rfcomm0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
Now you can write in this file like in a classic file :
sudo su -c "echo 'message' > /dev/rfcomm0"
and in theory read from it using
sudo tail -f /dev/rfcomm0
But I don't know read does not work, if any of you have an idea...
/def/rfcomm0
should be/dev/rfcomm0
– stewSquared
Feb 21 at 6:10
add a comment |
Here is my way to proceed to connect to a HC-05 bluetooth device plugged on my arduino. It does not need to write a file like in Brian's answer, but the idea is similar. I've tested it with a baud 9600 rate setup on the HC-05 device.
First step : pair the device and provide the PIN
I tried to setup from GUI the pairing, but it wasn't working. Here is the command line way to proceed that worked for me. First, let us pair the device from command line. Run :
sudo bluetoothctl
Be sure that the bluetooth device is started :
# power on
We now start the agent that will "remember the pin" for rfcomm
:
# agent on
Now we enable the scan mode to find our device and be able to pair it :
# scan on
After a few seconds the MAC of your device should appear. We will denote it as after. Then, you just need to pair the device like this :
# pair <MAC>
You will be asked to type a PIN, by default it's 1234
on my HC-05 device. You can note that it's possible that you device connect then disconnect with a message like that :
[CHG] Device 20:16:10:24:29:77 UUIDs: 00001101-0000-1000-8000-00805f9b34fb
[CHG] Device 20:16:10:24:29:77 ServicesResolved: yes
[CHG] Device 20:16:10:24:29:77 Paired: yes
Pairing successful
[CHG] Device 20:16:10:24:29:77 ServicesResolved: no
[CHG] Device 20:16:10:24:29:77 Connected: no
but it's not a problem. You do not need to connect, so you can now quit bluetoothctl
by typing Ctrl + D
.
Provide a usable file /dev/rfcomm0
Firstly, be sure that you didn't run any rfcomm command before. Indeed, even if you close with Ctrl+C
the program, it still run in background.
sudo killall rfcomm
Now, you can run
sudo rfcomm connect /dev/rfcomm0 20:16:10:24:29:77 1 &
Note that if you try to write on the input of rfcom, nothing happened. You need to use another program.
Third and last step : write into the /dev/rfcomm0
There are several ways to write on the file, but note that all ways to proceed involve root. I describe here several programs that can do that (so that you can choose depending on your need or on what is installed on your system for example). If you forget to run the program as root, you may have an error :
stty: /dev/rfcomm0: Device or resource busy
First option : connect using screen
Screen is a very powerfull tool. You can install it (it's always usefull anymore) by using :
sudo apt-get install screen
and then run
sudo screen /dev/rfcomm0
If you forget to run it as root, you will get an error like Aleksander got :
[screen is terminating]
To quit it, type "Ctrl A + :exit"
Second option : connect using minicom
Install it
sudo apt-get install minicom
and then run
sudo minicom -D /dev/rfcomm0
If you forget to run it as root, you will have an error like
minicom: cannot open /dev/rfcomm0: Device or resource busy
To quit it, type "Ctrl + A X".
Third option : python script miniterm
Download this script, and run :
chmod +x miniterm.py
sudo ./miniterm.py /dev/rfcomm0
Write directly into the file
Firstly run the following command (9600 is the baud rate) :
sudo stty -F /dev/rfcomm0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
Now you can write in this file like in a classic file :
sudo su -c "echo 'message' > /dev/rfcomm0"
and in theory read from it using
sudo tail -f /dev/rfcomm0
But I don't know read does not work, if any of you have an idea...
Here is my way to proceed to connect to a HC-05 bluetooth device plugged on my arduino. It does not need to write a file like in Brian's answer, but the idea is similar. I've tested it with a baud 9600 rate setup on the HC-05 device.
First step : pair the device and provide the PIN
I tried to setup from GUI the pairing, but it wasn't working. Here is the command line way to proceed that worked for me. First, let us pair the device from command line. Run :
sudo bluetoothctl
Be sure that the bluetooth device is started :
# power on
We now start the agent that will "remember the pin" for rfcomm
:
# agent on
Now we enable the scan mode to find our device and be able to pair it :
# scan on
After a few seconds the MAC of your device should appear. We will denote it as after. Then, you just need to pair the device like this :
# pair <MAC>
You will be asked to type a PIN, by default it's 1234
on my HC-05 device. You can note that it's possible that you device connect then disconnect with a message like that :
[CHG] Device 20:16:10:24:29:77 UUIDs: 00001101-0000-1000-8000-00805f9b34fb
[CHG] Device 20:16:10:24:29:77 ServicesResolved: yes
[CHG] Device 20:16:10:24:29:77 Paired: yes
Pairing successful
[CHG] Device 20:16:10:24:29:77 ServicesResolved: no
[CHG] Device 20:16:10:24:29:77 Connected: no
but it's not a problem. You do not need to connect, so you can now quit bluetoothctl
by typing Ctrl + D
.
Provide a usable file /dev/rfcomm0
Firstly, be sure that you didn't run any rfcomm command before. Indeed, even if you close with Ctrl+C
the program, it still run in background.
sudo killall rfcomm
Now, you can run
sudo rfcomm connect /dev/rfcomm0 20:16:10:24:29:77 1 &
Note that if you try to write on the input of rfcom, nothing happened. You need to use another program.
Third and last step : write into the /dev/rfcomm0
There are several ways to write on the file, but note that all ways to proceed involve root. I describe here several programs that can do that (so that you can choose depending on your need or on what is installed on your system for example). If you forget to run the program as root, you may have an error :
stty: /dev/rfcomm0: Device or resource busy
First option : connect using screen
Screen is a very powerfull tool. You can install it (it's always usefull anymore) by using :
sudo apt-get install screen
and then run
sudo screen /dev/rfcomm0
If you forget to run it as root, you will get an error like Aleksander got :
[screen is terminating]
To quit it, type "Ctrl A + :exit"
Second option : connect using minicom
Install it
sudo apt-get install minicom
and then run
sudo minicom -D /dev/rfcomm0
If you forget to run it as root, you will have an error like
minicom: cannot open /dev/rfcomm0: Device or resource busy
To quit it, type "Ctrl + A X".
Third option : python script miniterm
Download this script, and run :
chmod +x miniterm.py
sudo ./miniterm.py /dev/rfcomm0
Write directly into the file
Firstly run the following command (9600 is the baud rate) :
sudo stty -F /dev/rfcomm0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
Now you can write in this file like in a classic file :
sudo su -c "echo 'message' > /dev/rfcomm0"
and in theory read from it using
sudo tail -f /dev/rfcomm0
But I don't know read does not work, if any of you have an idea...
edited Feb 26 at 10:11
answered Jan 9 '17 at 19:42
tobiasBoratobiasBora
943810
943810
/def/rfcomm0
should be/dev/rfcomm0
– stewSquared
Feb 21 at 6:10
add a comment |
/def/rfcomm0
should be/dev/rfcomm0
– stewSquared
Feb 21 at 6:10
/def/rfcomm0
should be /dev/rfcomm0
– stewSquared
Feb 21 at 6:10
/def/rfcomm0
should be /dev/rfcomm0
– stewSquared
Feb 21 at 6:10
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f248817%2fhow-to-i-connect-a-raw-serial-terminal-to-a-bluetooth-connection%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you doing Bluetooth->Serial, Serial->Bluetooth, or two-way?
– hexafraction
Jan 29 '13 at 0:14
Totalstation Bluetooth<->Ubuntu Bluetooth. Given that the totalstation has the standard serial configuration over USB, I suspect it is establishing a serial connection over Bluetooth. Of course, I could be completely wrong, at which point the answer that I'm wrong and the bluetooth uses XYZ is completely permissible.
– Brian Ballsun-Stanton
Jan 29 '13 at 0:18
In terms of the two-way proof, I have managed to establish a blank serial connection via "screen" that causes an error beep on the device when I hit a key on the keyboard. So I suspect that I'm half-way there, I just don't know which half.
– Brian Ballsun-Stanton
Jan 29 '13 at 0:19
Can you draw up a quick diagram? I can't understand whether it's serial over or bluetooth over serial, as well as who's passing on the data to where. Just do it in GIMP or something and upload it here
– hexafraction
Jan 29 '13 at 0:20