PyBluez + LeJOS

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

PyBluez + LeJOS

Postby poohsen » Sun Nov 20, 2011 2:13 pm

hi there,

I'm not an expert when it comes to Bluetooth, or protocols, or streams, so please, correct me whereever I went wrongt. Here's what I'm trying to do:

I'm trying to send data from a python script to my NXT brick (which is using lejos, of course). The basic BT setup works, I can send data to my NXT with the BTSend prog from the pcsamples.
The problems begin when python comes into play. from what I gathered so far, I can only send RFCOMM protocol messages or (via a special NXT python package) Lego Bluetooth protocol messages with python (using pybluez).

Looking at the NXTConnection and NXTInputStream classes, I see plenty of low-level stuff involving headers, bit shifting operations and what not. My guess is that whatever it is the lejos developers are doing there needs to be done on the sender as well, which it is when you use the lejos classes for sending data, but not when you use python.

So, my question basically is: do you guys think I need to reimplement this stuff from NXTConnection in python to send data (like Integers, for instance) from a python script to my NXT brick? Or is there any other way for me to send a message lejos will understand?
It looks like no one even mentions pybluez in this forum... doesn't seem to be a common usecase :)

Thanks in advance,
poohsen
poohsen
New User
 
Posts: 20
Joined: Sun Nov 20, 2011 1:47 pm

Re: PyBluez + LeJOS

Postby poohsen » Tue Nov 22, 2011 7:05 am

ok, I got rid of the dataInputStream form the BTReceive sample. Just writing data to an RFCOMM socket still wouldn't work as expected, but using the NXT Python's brick.message_write() I can finally send and read data. Still need to figure out how to build a "received" reply for message_write() in Java, but that should be doable.

poohsen
poohsen
New User
 
Posts: 20
Joined: Sun Nov 20, 2011 1:47 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 6 guests

more stuff