This posting is older than 6 months and can contain outdated information.
On Tue, Nov 8, 2011 at 11:20 AM, WilliamK
wrote:
I'm wondering if it would be possible to integrate the Arduino Serial interface somehow?
Here's an idea, an option to send key-commands to a serial port from within Remote Buddy itself, that would be great. And no, I have no clue on how to use scripts, so unless someone helps me out... ;-) ;-)
I'm currently using a Mini MAC, and was hoping I could send some data to a serial port when I press a key on my Wiimote, or even the Infrared remote.
I have done something like this, and on a Mac Mini too. The trick is
to write a command-line program to be invoked in the terminal. The
Remote Buddy program then allow you to call Applescript with "do shell
script" to invoke the relevant command.
PS3 Bluetooth remote has 52 keys. These are mapped in Remote Buddy to
custom actions / mappings. Remote buddy then just simply executes some
terminal command like:
do shell script "~/Library/bin/arduino-serial -b 115200 -p
/dev/tty.VELLEMANK8022-DevB -d 1 -s \"18;\""
Where the -s "18;" is the command string (in plain ASCII) to send as
the raw serial data over the comm port to the listening Arduino
device. The /dev/tty.VELLEMANK8022 is of course the name of the serial
device (a bluetooth HC05 serial port, wired directly to the TX and RX
pins of the Arduino ATMEGA 328 chip).
On the arduino side, I have a sketch loaded which runs in a loop and
polls the Serial port for interpreting the Serial communications.
Thats the open source CmdMessenger library which was updated and
written on the Arduino IDE.
To keep the serial port open (which stops the huge delay incurred by
the Arduino resetting on the DTR signal each time the comm port is
opened) - its also necessary to run the 'cat' unix command as a
background launchd process on OS X. The Launchd KeepAlive flag ensures
that the connection is re-opened from the PC side if the comm
connection if its interrupted or cuts out for any reason.
You can find all of the necessary source code for these programs (all
except for the launchd background process) on my github account. You
will get that too if you message me on github (dreamcat4). Its all
open source software as per the Arduino comminity site.
Another idea would be to RECEIVE commands from the Arduino. One solution I'm thinking is have the Arduino output Keyboard-USB commands, then just use those inside Remote Buddy, but that requires extras parts.
Its harder to understand how that kind of job is meant to be a part of
remote buddy. But I imagine you mean controlling a virtual USB
keyboard in the same way as RB has virtual remotes devices? So any
local or global key press combination on the PC could be actuated from
the Arduino device? I think Felix would argue that many OS X
applications can be remote-controlled through applescript these days.
For the Arduino bit, you would also need some kind of constantly
listening Demon or background process running on your OS X box. I mean
not just simply the unix 'cat' command, but some demon which contains
specific handlers to be triggered by the commands in the arduino
serial data and convert those serial commands into specific keypress
events for Mac OS X. Its something that requires a lot more thought.
Setting aside Remote Buddy for the moment, there exist certain other
shareware programs for Mac OS X which do try to solve this specific
problem. For example Keyboard Maestro comes to mind. I'm really not
sure which Apple specific Apple Cocoa APIs are relevant here. Its
certainly possible to do in OS X since Keyboard Maestro does it. But
you'd have to look considerably further into the matter. There is some
great value in finding out about this capability however. Especially
for HTPC / home theatre.
What I did was to successfully implemented communications in one
direction. From PC -> Arduino, and not the other way around.
By expecting my Arduino device to comply with any instructions given,
and reliably carry out each command to the letter with no questions
asked. Be that changing the volume of the hifi, selecting an audio
channel, or forwarding commands to the secondary daisy-chaned remote
device (eg a 2nd slaved PS3 controller via custom logic circuit, or
remote power bar).
Sometimes it is relevant to know the state that a slave device is
currently in. So rather than actually asking the Arduino each time,
the shell script simply touches an empty file in the user's home
directory to note that the command was actioned. Which is a persistent
a state setting between invocations and reboots. To the PC can always
discern whether the device was on or off last time. A simple file
check the next time the command is invoked allows those types of
actions to be alternated eg off->on->off->on. Its a very simple
system.
Thanks for any ideas.
[standard mail footer removed]