Pages: [1] 2   Go Down
Author Topic: Serial communication with nslu2  (Read 2648 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 45
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I have on old linux NAS device, the nslu2 (aka Slug).

The device has a serial port on the board, as soon as you solder three pins into the right holes.

I did that and connected digital ports 0 and 1 of the arduino uno with the pins on the nslu2's serial port.


Communication works "kind off" ...

I installed zoomkat's  check script on the arduino (found it here in the forum):
Code:
// zoomkat 8-6-10 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later

String readString;

void setup() {
     Serial.begin(9600);
       Serial.println("serial test 0021"); // so I can keep track of what is loaded
       }

void loop() {

       while (Serial.available()) {
       delay(10);  
         if (Serial.available() >0) {
       char c = Serial.read();
       readString += c;}
       }
      
     if (readString.length() >0) {
     Serial.println(readString);
    
     readString="";
     }
  }


Then I connected to the slug via ssh and entered the following (after setting the speed to 9600):

echo 1 > /dev/ttyS0

On the Arduino's serial console I got this:

serial test 0021

and sometimes I get this:

ÿ

What I need: a number between 0 aund 1023 on the arduino has to show up on the slug as the same number.
And reverse:

Any ideas?

Schwabinger
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 45
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And here is a link with the description on how to build the serial interface>

http://ezinearticles.com/?Arduino-Serial-to-Ethernet-Using-an-NSLU2---Technical-Details&id=4996214
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49376
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When the serial port is opened, or closed, the Arduino resets.

When you echo something to the serial port that way, it may be opening the serial port again, causing a reset.

The y with the two dots over it is caused by printing a -1 as an ASCII character. The -1 comes from trying to read data from the serial port, when there is no data to read.

It does not appear that that should happen, given the code that you are running.

Does the "serial test 0021" get printed every time you echo something to the serial port?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 45
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your help.

Sometimes there is no replay at all.
And then there are phases where every time I send an echo from the nslu2, I receive the y.

And now received this:

serial test 0021
i[ch149]^
þ
Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9627
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not sure about your setup. Can you explain in more detail what is connected to what, and how? I assume you have a pc connected via usb to the arduino, and a slug connected in parallel to the arduino using the arduino tx/rx pins. Who is sending the data, and what form is the data? What does the slug do and are you communicating to the slug seperately?
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Newbie
*
Karma: 0
Posts: 45
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sorry for not beeing very precise.

My project:

Use an arduino together with a pot to send numbers from 0 to 1023 to a slug via the serial port (not usb-servial). The slug has a usb-soundcard und plays internet radios stations. When you turn the pot, it switches to a different station. (Idea and working showcase has been done by "MightyOhm" with a different hardware.)

The communication from arduino to the slug works now. I power arduino now with it's own power supply and not via usb ... so there is no mixing up between  the usb-serial and  the cable-serial (pins 0, 1)

In addition to that I had to pull the cable that goes from the slug to arduino's RX pin. The slug sent data from time to time that reset the arduino's serial port (resulting in the Y characters)

On the slug I first tried to read the serial input with

cat < /dev/ttyS0
or
tail -f < /dev/ttyS0

but neither worked.

The only configuration that works at the moment is using minicom.

So I start

minicom -C fromarduino.txt

and every second the pot's numerical value is added to that file.
Using tail I extract the last line and use that as input to control mpc (the sound client, that plays the internet radio stations)

So what I still need is the following:

I want to send information back from the slug to arduino. How do I have to configure the serial port on the slug so that arduino can receive data like:

"Radio Luxembourg" or at least a number like 31 (station number).


Regards,

Schwabinger





Logged

Cumming, GA
Offline Offline
Edison Member
*
Karma: 20
Posts: 1655
Ultimate DIY: Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Something to keep in mind.  Either of these two devices may have limited buffer space for serial data (if any at all).  I have seen cases where some delay is required between "lines" to allow time for the processing of the line to occur... and without some delay the next line of Ascii will stomp on it.  I've only seen this with embedded type devices... but that sort of fits the description of the SLUG and the Arduino.
Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9627
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The communication from arduino to the slug works now. I power arduino now with it's own power supply and not via usb ... so there is no mixing up between  the usb-serial and  the cable-serial (pins 0, 1)

I'm not sure you have to do that seperation. I've had an ssc-32 servo controller connected to the arduino tx pin while connected with the serial USB. This allowed me to monitor what the arduino was sending to the ssc-32 using the serial monitor. Not sure if the rx lines need to be seperated.

Quote
In addition to that I had to pull the cable that goes from the slug to arduino's RX pin. The slug sent data from time to time that reset the arduino's serial port (resulting in the Y characters)

How can this reset the arduino serial port (not sure what you mean here)? The arduino main reset is controlled via the DTR pin on the USB input. Don't understand your serial reset is.

I agree you may need to test a delay in your code to prevent sending too much data. You might also incorporate a loop check that does not send data out the serial port if the data has not changed since the last send. As to the "number" being sent, does the slug expect to get an ascii character string representing the number, or maybe two bytes?  
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Newbie
*
Karma: 0
Posts: 45
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your answers.

I think I was not right in stating that arduino resets the serial communication, when it sends this special y character to the slug.

PaulS explained it in this way:

Quote
The y with the two dots over it is caused by printing a -1 as an ASCII character. The -1 comes from trying to read data from the serial port, when there is no data to read.

It does not appear that that should happen, given the code that you are running.

The code I run on the Arduino is simple:

Code:
void setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue, DEC);
  delay(500);
}

Schwabinger
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49376
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
 int sensorValue = analogRead(A0);
One of the dumbest things the Arduino team ever did was introduce those stupid aliases and then misuse them in all the examples. On a Duemilanove, A0 has a value of 14. Do you have that many analog pins on your board? If not, why are you trying to read from analog pin 14?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 45
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am not sure wether I understand you right, but I do not use analog pin 14. I use analog pin 0 to read the pot's input.
I use a new UNO board ...

Schwabinger
« Last Edit: December 12, 2010, 04:27:07 pm by Schwabinger » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49376
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please re-read what I said. A0 is defined in WProgram.h to have the value of 14.
Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9627
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The below might be useful for basic troubleshooting.

http://arduino.cc/en/Reference/AnalogRead
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Newbie
*
Karma: 0
Posts: 45
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The status of my project is the following:

  • Arduino sends the data of a pot to the slug via the serial cable. (ok)
Slug reads the input (using minicom -C filename) into a file. (ok)[/list]
Shellscript reads the file and makes mpd/mpc select and play one of about 35 internet radio stations. The position of  the pot decides which station will be played (ok)[/list]
All the above only works under the following conditions:

I set the following parameters:
stty -F /dev/ttyS0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts

Slug's TX (Arduino's RX) wire is disconnected.

If I do not disconnect this wire, after several Minutes the arduino sends the following:

ÿÿÿÿÿÿÿÿÿ and then it stops sending (ore minicom stops receiving ...)


Any ideas what I have to change in my configuration in order to keep and use the serial connection back from slug to arduino?

Do you think that switching from analog pin 0 to a different pin would change anything?

Regards,

Schwabinger

« Last Edit: December 13, 2010, 04:12:51 pm by Schwabinger » Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9627
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd go back and run the arduino connected to the USB and the slug connected to the arduino tx/rx/gnd board pins, and observe what the arduino is sending out using the arduino IDE serial monitor. Then compare what the serial monitor displays to what ever is displaying the ÿÿÿÿÿÿÿÿÿ. This way you can see if the arduino stops sending data and compare what is sent to what is received.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Pages: [1] 2   Go Up
Jump to: