Wow, thanks again for your input (you must be able to tell I'm a novice).
I'll reply to thew best of my knowledge....
Why? inData is perfectly acceptable as input to atol(), as long as it contains only numeric data (which making a pointer to point does nothing to ensure).
For some reason, I couldn't get atol() to work with my inData variable.
Pretty optimistic, aren't you?
My video is close to reaching 1000,000 views on YouTube, this counter is part of the celebration although it's looking like this serial problem might mean the project doesn't get done in time.
This tells me that AppleScript is not configuring the serial port correctly.
The big issue is the serial monitor problem. I am using a command line tool to send that data to the serial port, the tool is specifically written for Arduino. Information on that tool is here.
http://todbot.com/blog/2006/12/06/arduino-serial-c-code-to-talk-to-arduino/ I have hacked my script apart to just the basics as that might help discover the issue.
Basically all it does is:
Wait for something from the serial port.
If it is "<" then collect all of the following characters.
Once it get ">" stop reading the data.
Print data to the LCD.
Again this script only functions correctly if the serial monitor is open.
One more behavior is that if I open the serial monitor then close it, it often still works. Could it be that the serial monitor is doing some kind of initialization of the serial port?.
Anyway, here is my simplified code.
#define SOP '<'
#define EOP '>'
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
bool started = false;
bool ended = false;
int countStrt = 0;
char inData[80];
byte index;
int timeout=0;
int timeoutFlag=0;
long previousCount = 0 ;
void setup()
{
Serial.begin(57600);
lcd.init();
lcd.backlight();
lcd.clear();
}
void loop()
{
while(Serial.available() > 0)
{
char inChar = Serial.read();
if(inChar == SOP) //start packet
{
index = 0;
inData[index] = '\0';
started = true;
ended = false;
}
else if(inChar == EOP)
{
ended = true;
break;
}
else
{
if(index < 20)
{
inData[index] = inChar;
index++;
inData[index] = '\0';
}
}
}
// We are here either because all pending serial
// data has been read OR because an end of
// packet marker arrived. Which is it?
if(started && ended)
{
// The end of packet marker arrived. Process the packet
// Serial.println(inData);
lcd.clear();
lcd.print(inData);
started = false;
ended = false;
index = 0;
inData[index] = '\0';
}}
I would LOVE to figure this out before my video reaches 1000,000 views !!!
Thanks again.
Phil