Pages: [1]   Go Down
Author Topic: flash interfacing on os x  (Read 1837 times)
0 Members and 1 Guest are viewing this topic.
Montreal, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hey
i just got my arduino board today (very cool, by the way) and i'm trying to interface with flash but i am having a little problem.

i make the connection and it works and flash and arduino seem to be communicating but this is the output i get:
- Flash: Hi Arduino, can you hear me?
????????????????????x?

?~?~???f

0
?`
?
3?f?????f???`
?
?x3???


???

0f?
?f?

what's up with that arduino response? that's not normal, is it? i also get the same kind of thing when i use the monitor with the serial_comm examples.

here's my system info:
- arduino 04 on os x
- usb board
- using port /dev/cu.usbserial-1B1

thanks for the help!
« Last Edit: May 17, 2006, 11:12:52 pm by prisonerjohn » Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It may be a mismatch between the baud rate the Arduino board is using to communicate over the USB/serial port and the baud rate the software on the Mac is using.

What are you using to forward data between Flash and the board?  serproxy?  What code is running on the Arduino board?
Logged

Montreal, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

the code running on the board is from the flash example that you posted in this forum.  according to it, i'm using a baud rate of 9600.  do i have to change this value?  

i am using serproxy, by the way

here is the code (stripped from comments):
Code:
/* ------------------------------------------------
* ARDUINO CONVERSATION
* by beltran berrocal, b@progetto25zero1.com
*
* created 30 Decembre 2005;
* copyleft 2005 Progetto25zero1  <http://www.progetto25zero1.com>
* --------------------------------------------------- */

char serInString[100];
int sentenceNum = 0;  


void readSerialString (char *strArray) {
    int i = 0;
    if(serialAvailable()) {    
       while (serialAvailable()){            
          strArray[i] = serialRead();
          i++;
       }
    }      
}


void printSerialString(char *strArray) {
     int i=0;
     if (strArray[i] != 0) {    
         while(strArray[i] != 0) {
            serialWrite( strArray[i] );
            strArray[i] = 0;                  // optional: flush the content
            i++;          
         }
     }
}


boolean isStringEmpty(char *strArray) {
     if (strArray[0] == 0) {
         return true;
     } else {
         return false;
     }
}


void sendStringToFlash (unsigned char *s) {
      while (*s) {
          printByte(*s++);
        }
        printByte(0); //notify the XMLSocket that the comunication is over
}


void ArduinoConversation(int i) {
  if(i==0)        {sendStringToFlash("Arduino: Mamma mia Flash, Yes I can hear yu!");
  } else if(i==1) {sendStringToFlash("Arduino: well, let's go have a BIRRA together, wat do yu tink?");
  } else if(i==2) {sendStringToFlash("Arduino: don't worry! it'll just make my pins go analog analog ;-)");
  } else if(i==3) {sendStringToFlash("Arduino: glu glu glu! your turn now dude, insted of just lurking... ask me something!");
  } else if(i>=4)  {
      printString("Arduino: unfortunately for you my master is smart as one of my digital pins ;-) ,");
      printString(" which means that I don't have an answer for that yet!");
      printString(" I'll ask babbo 'touring' natale to give me a neural network for handeling natural speaking next time");
      printByte(0); //end of communications in XMLSocket
  }
}


void setup() {
  beginSerial(9600);  //setup serial conversation at 9600 bauds
}


void loop () {
  readSerialString(serInString);
  
  if( isStringEmpty(serInString) == false) {
      printString("Arduino heard you saying: ");
      printSerialString(serInString);
            
       printByte(0);
      
      ArduinoConversation( sentenceNum );
      
      sentenceNum++;
  }
  
  delay(2000);
}
« Last Edit: May 18, 2006, 07:58:18 am by prisonerjohn » Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the serproxy defaults to 19200 baud, so you'll need to change one of them.  Either edit the beginSerial line in the Arduino code or the comm_baud parameter in the serproxy.cfg file.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 134
panta rei resist the resistors!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

yes that might be it!
the serial proxy configuration defaults to 9600 bauds (at least the version I've got locally)

# Default settings
comm_baud=9600

either edit this or the beginSerial value in the Arduino code


another thing that sometimes happens is that EVEN if the bothe speed are the same
somenthing goes wrong in the exchange and the two processors start talking nonsense to each other

a very simple solution to this problem is to reset the arduino board (through its reset button)
while the serial connection is still open...everything will work perfectly

cheers
b.
« Last Edit: May 18, 2006, 01:59:04 pm by beltran » Logged

Montreal, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

sounds good
i'll give it a try when i get home from work and post the outcome
Logged

Montreal, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hey
the baud rate was the problem, i changed it to 19200 and it works great
thanks for the help!

also, I forgot to mention this, but I get the following error when I compile the Arduino source:
 In function 'void ArduinoConversation(int)':
error: invalid conversion from 'const char*' to 'unsigned char*

i just took out "unsigned" from the sendStringToFlash() function and it compiles properly.
beltran, you may want to look into that...
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 134
panta rei resist the resistors!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for pointing it out...
are you compiling it with arduino4?
the fact is that I've never tryed it yet with arduino4...and heard other people around are having this kind of problems: code written for previous versions of arduino seem to be buggy in arduino4...

this is a question for mellis: is it a backwards compatibility problem or is it that previous versions of arduino led us all to bad coding conventions?

cheers
b.
Logged

Montreal, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

>>are you compiling it with arduino4?
 
yes i am
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
thanks for pointing it out...
this is a question for mellis: is it a backwards compatibility problem or is it that previous versions of arduino led us all to bad coding conventions?

A little of both.  Arduino 0004 compiles sketches as C++ (whereas Arduino 0003 used C) which allows use to use the nice, Processing-like syntax for serial communication and other library.  C++, however, is stricter about some things, like types and function prototypes.  In general, though, it should be relatively easy to get things working.  As usual, I'll try to help people who post in the forums, and summarize the main issues in the FAQ.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 134
panta rei resist the resistors!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

does that mean that if in arduino3 you could write any C code in the sketch
now in arduino4 you should could write code in C++???

if that is the case do you have any good online reference or resource to maybe post on the playground wiki so that people can learn c++ and the differences between it and simple C?

any ideas?
thanks in advance
cheers
b.
Logged

Pages: [1]   Go Up
Jump to: