1

My question may looks trivial... But it's because despite of my long experience of linux/unix/osx systems, I found myself lacking some basic notions.

I created a little bluetooth/arduino switch to control some appliances at home. It's a simple program like shown here http://www.tinkernut.com/2014/03/arduino-bluetooth-basics/

To enable or disable my switch, I do :

screen /dev/tty.HC-06-DevB

Then I type 0 or 1 in the console and my switch goes On or Off.

It works. Really, it's nothing difficult... Except that I don't know the principles behind the communication with the ressources located in /dev/ and I don't know how to start learning.

How can I have a simple commande to send 1 or 0 to this particular device? Something like:

echo 1 > screen /dev/tty.HC-06-DevB

I tried the command below, it doesn't work:

echo 1 > /dev/tty.HC-06-DevB
zsh: resource busy: /dev/tty.HC-06-DevB

Where to learn what are these "things" in /dev ?

PS : I am using OS X El Capitan.

Charaf
  • 321

2 Answers2

0

Here's the manual for screen. Look for the specific command line options to the screen that you're interested in.

For example, -r reattaches to a detached screen process.
-R reattaches if possible and starts a new session otherwise. I think this is the option you're looking for.

So, I'd do:

$ screen -R /dev/tty.HC-06-DevB

Also from the manual page:

-D (-r) Detach and logout remote (and reattach here).

Feel free to comment if you think I misunderstood something.

Bibek_G
  • 549
0

After many reading, and thanks to Bibek_G's answer which helped me to find some links on the internets, I finally understood what I need and how to make thing work. Actually, what I want to do doesn't need screen... The right command was :

sudo echo 1 > /dev/cu.HC-06-DevB

It didn't work at the beginning because I didn't use sudo.

By the way, I also learned how to use screen.

Thank you all.

Charaf
  • 321