How to set up serial communication during processing in / dev / rfcomm0

I am trying to do serial communication between Ubuntu 12.04 and a JY-MCU bluetooth serial module connected to an Arduino.

I created this configuration in /etc/bluetooth/rfcomm.conf

rfcomm0 {
#   # Automatically bind the device at startup
    bind yes;
#
#   # Bluetooth address of the device    
    device 00:12:11:19:08:54
#   # RFCOMM channel for the connection
    channel 1;
#   # Description of the connection
    comment "Linvor Bluetooth Module";
}

I can use putty to communicate with the serial port / dev / rfcomm 0, and this works fine.

However, despite many attempts, I just donโ€™t see how to create a serial port in processing that works in any way.

For instance:

println(Serial.list());

nothing output.

If I do:

String portName = "/dev/rfcomm0";
myPort = new Serial(this, portName, 9600);
println(myPort);

I see this on the monitor:

processing.serial.Serial@1712651

But if I then call:

 myPort.write('9');

I get an exception:

java.lang.NullPointerException
    at processing.serial.Serial.write(Serial.java:572)
    ...

I do not understand why this fails. I follow all the instructions from Tom Igoe's โ€œMaking Things Talk,โ€ but that just doesn't work the way he says ...

Any help would be great!

Thank,

Bean

+5
2

.

, rxtx java (RXTX-2.1-7) .

RXTX wiki :

"rxtx /dev , , 'ttyS', 'ttym', 2.2 'ttyUSB' ."

Bluetooth rfcomm*, .

fool rxtx ( ttyS, ):

$ sudo ln -s  /dev/rfcomm0 /dev/ttyS99

:

$ sudo rfcomm connect 0
 Connected /dev/rfcomm0 to 00:12:11:19:08:54 on channel 1
 Press CTRL-C for hangup

JY-MCU , :

println(Serial.list());

:

[0] "/dev/ttyACM0" 
[1] "/dev/ttyS99"

, .

, script JY-MCU linux BlueZ

:

  • JY-MCU,

  • , 00: 12: 11:19: 08: 54

    $ hcitool scan  
    
  • /etc/bluetooth/rfcomm.conf; , 0 rfcomm, :

    $ cat /etc/bluetooth/rfcomm.conf
    rfcomm0 {
        bind yes;
        device 00:12:11:19:08:54;
        channel    1;
        comment "Linvor Bluetooth Module";
    }
    
  • BlueMan JY-MCU.

, JY-MCU

  • :

    $ sudo ln -s  /dev/rfcomm0 /dev/ttyS99
    
  • JY-MCU:

    $ sudo rfcomm connect 0
      Connected /dev/rfcomm0 to 00:12:11:19:08:54 on channel 1
      Press CTRL-C for hangup
    
  • script JY-MCU :

    String portName = "/dev/ttyS99";
    myPort = new Serial(this, portName, 9600);
    
  • script, , CTRL-C JY-MCU.

! ,

+8

- . , 1, . , , .

sdptool browse local

, , Ubuntu.

0

All Articles