Send serial data without the IDE?

I've been doing searches to answer this question, but nothing has come up. I have a Leonardo, and I want to pass it the current time, ideally through a shell script that I can execute when the computer boots up. How do I pass serial data to the Leonardo through the command line? (I'm using Mac OS X.)

Many thanks, Carl

I want to pass it the current time, ideally through a shell script that I can execute when the computer boots up.

Were the Mac up and running with the Leonardo connected, the Arduino would be a virtual com port by virtue of the iOS USB driver... Then you could simply script the current time into a variable and echo that variable as a redirect to the virtual com port. In Windows, the ECHO command could simply be used with a redirect to the virtual com port.

However, at boot-up time, I am unsure if iOS would have enumerated the USB to a virtual com port and I am unsure how you can configure iOS to always assign the same virtual com port number; therefore the script may need some intelligence to integrate the environment while waiting until all USB enumerations are complete. Assuming the Arduini is always the same serial port number, then you would simply redirect an echo of time-date to the appropriate comport.

Ray

I am unsure how you can configure iOS to always assign the same virtual com port number

The Mac OS does not use com port numbers like the crude PC system. It uses com port names generated from the USB ID. Therefore it always comes up the same every time. Unlike a PC which can come up differently.

The simplest way is to use a program under processing, but a shell script should work as well. Simply use the name of the com port like you would any other command line echo output.

As Grumpy_Mike suggests, you would need to write a shell script or console application which read the current time and wrote it to the Arduino's serial port in a format that the Arduino expected. It would make sense to configure the OS to run this at OS boot time, or perhaps to run it at regular intervals if this is intended to keep the Arduino clock synced to the PC.

@Grumpy_Mike:

The Mac OS does not use com port numbers like the crude PC system. It uses com port names

Darn-it.... In was sooooo close to the answer but still light-years away :grin: Is this like horseshoes where I get partial points?

(Generally Windoz will give same port number if the same external USB connector is used)

Ray

Thanks, everyone.

@PeterH, that is precisely what I'm trying to do - write a shell script to pass the current date to the Arduino.

@Grumpy_Mike, I am trying to echo a string to the Arduino. The IDE says that there is an Arduino Leonardo connected on /dev/tty.usbmodem1411, but when I run echo '1' > /dev/tty.usbmodem1411, I get: /dev/tty.usbmodem1411: cannot create [Input/output error]. I run it in sudo with a same result. Any ideas? Thanks.

carlsigmond: when I run echo '1' > /dev/tty.usbmodem1411, I get: /dev/tty.usbmodem1411: cannot create [Input/output error]. I run it in sudo with a same result. Any ideas? Thanks.

Does the Arduino reset when you run that command?

PeterH: Does the Arduino reset when you run that command?

No, the Arduino doesn't reset, but here's what happens: When I run that command, I get nothing (no next prompt, no error, nothing). If I do Control+C, that's when I get the cannot create [Input/output error]. After running the command, the Arduino runs normally for about thirty seconds and then appears to freeze until I cancel the echo command, but it doesn't reset.

I don't know what's involved in configuring the serial port with that OS, but perhaps there's something you need to do to set the serial parameters (speed, start/stop bits, parity). I don't see why that would cause the symptoms you're describing, but it's all I can think of.

Have you read this in configuring the serial port? http://stackoverflow.com/questions/3918032/bash-serial-i-o-and-arduino