Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : how to get processing on Linux to communicate via rfcomm

$
0
0
After searching high and low, I have made this work.
The key issue is that processing uses the rxtx java library (RXTX-2.1-7) for serial communications.
The RXTX wiki says:
"rxtx tries to detect ports on by scanning /dev for files matching any of a set of known-good prefixes, such as 'ttyS', 'ttym', and since 2.2 'ttyUSB' and so on. "
And since the bluetooth device is named  rfcomm* it cannot be detected.
The trick is to create a sym link to fool rxtx (use a ttyS device that is not yet assigned):
  1. $ sudo ln -s  /dev/rfcomm0 /dev/ttyS99
Then, connect:
  1. $ sudo rfcomm connect 0
  2.  Connected /dev/rfcomm0 to 00:12:11:19:08:54 on channel 1
  3.  Press CTRL-C for hangup
At this point the red led on the JY-MCU becomes solid and processing can detect it:
  1. println(Serial.list());
output is:
  1. [0] "/dev/ttyACM0"
  2. [1] "/dev/ttyS99"
So, serial communication can work.
To summarize, the following process will allow a processing script to communicate via a serial port with a JY-MCU device in a BlueZ linux framework

One time setup:
1. power up the JY-MCU,
2. use the following command to get its hardware address, mine is 00:12:11:19:08:5
  1. $ hcitool scan
3. use that to create the /etc/bluetooth/rfcomm.conf file; you'll note that I chose 0 for the rfcomm device,
   we need that for connection later:       
  1. $ cat /etc/bluetooth/rfcomm.conf
  2.         rfcomm0 {
  3.             bind yes;
  4.             device 00:12:11:19:08:54;
  5.             channel    1;
  6.             comment "Linvor Bluetooth Module";
  7.         }
4. use BlueMan to pair the JY-MCU.
That ends the one-time setup.

Then, every time you want to use the JY-MCU
 1. create the sym link:
  1.  $ sudo ln -s  /dev/rfcomm0 /dev/ttyS99
2. connect to the JY-MCU:
  1. $ sudo rfcomm connect 0
  2.  Connected /dev/rfcomm0 to 00:12:11:19:08:54 on channel 1
  3.  Press CTRL-C for hangup
3. you can now run a processing script and connect to the JY-MCU with the code:
  1. String portName = "/dev/ttyS99";
  2. myPort = new Serial(this, portName, 9600);
4. after running the processing script, be sure to CTRL-C at the
    command line to disconnect the JY-MCU.

That should do it!
Ciao,
Bob


Viewing all articles
Browse latest Browse all 1768

Trending Articles