Go Down

Topic: Reading Serial Data from USB host (Read 9416 times) previous topic - next topic

mamu

The problem is you are trying to use ttyATH0 which is in use by Yuns bridge implementation.
Try using another port or modify inittab.

federicofissore

It depends on the device you're plugging to the you, but you'll need additional kernel modules for talking to another Arduino (say a UNO) plugged to the yun. Try
Code: [Select]

opkg update
opkg install kmod-usb-acm

lordk

#17
Jun 16, 2014, 07:10 pm Last Edit: Jun 16, 2014, 07:16 pm by lordk Reason: 1
Federico,

the linino(UBS host) <-> FDTI is working. I can read in the python console the Strings coming up from the FTDI, what I cant make it work is the Arduino<-> linino communication.-

edit: Commenting the line in inittab seems to work. Can I change the serial1 port as MAMU suggested so I leave inittab as default??

mamu


edit: Commenting the line in inittab seems to work. Can I change the serial1 port as MAMU suggested so I leave inittab as default??

Sadly, no.

lordk

It has to be a easy way to send data from linino to ATmega without mixing data.

mamu

Yes, there is an official Yun way: use bridge.
If you want to go down your own road, like I did by using serial1, you have to modify inittab.
Btw: you can give SPI communication a chance. But even here, you are on your own.

lordk

I dont know how to do it, but looking the examples I think that i need to change the approach to this,

Now i have:
ftdi (data 1 x second) -> linino (python bridge) -> atmega (serial1.available?)

With Bridge I think that I need a do a "get" from the atmega to ftdi. right?
atmega (get evert second) -> linino (python bridge) -> ftdi (need to send data?)

federicofissore

Bridge is a general purpose way of doing (almost) everything.
If you don't need all its features and in particular if you do NOT need to run processes, the inittab trick leaves you a clean communication channel and it's definitely much better

Jantje

#23
Jun 16, 2014, 11:19 pm Last Edit: Jun 17, 2014, 12:26 pm by Jantje Reason: 1

Bridge is a general purpose way of doing (almost) everything.
If you don't need all its features and in particular if you do NOT need to run processes, the inittab trick leaves you a clean communication channel and it's definitely much better

I'm running processes without the bridge without problems. Both on my yun as on my yun/mega setup.
I simply send "EXEC:command to be executed" over the serial port.
The listener on the linux site is a batch file and runs this code
Code: [Select]

while read line
do
...
       FIRST=`echo $line | cut -d';' -f1 |cut -d':' -f1`
....
       elif [ "$FIRST" = "EXEC" ]; then
         COMMAND=`echo $line | cut -d':' -f2`
         ${WebLocation}/${COMMAND}>>${PortName} &
       fi
done


So basically it runs the command in the folder ${WebLocation} and sends the output back to the arduino by rerouting the output to ${PortName} which translates to /dev/ttyATH0

The folder is important because the path is not set in the same way as when you are logged on.

Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

lordk

Federico, with the  inittab trick is working. I power up the YUN, wait till the USB is turn on, and then plug my FTDI device. Data is shown in Arduino IDE.






sonnyyu


...
Btw: you can give SPI communication a chance. But even here, you are on your own.


I2C is the second on line.

federicofissore


mamu

@jantje: could you share some code for you arduino sketch? Have you modified inittab?

Jantje

I have written 2 articles on my blog explaining how  I do it. This all predates yun and lots has been changed since that day, but the basic foundation still stands.
http://blog.baeyens.it/#post7
http://blog.baeyens.it/#post8
The execution is something I added quite recently and I have not yet posted the latest code on github. Previous versions are the serial libraries here.
https://github.com/jantje/libraries
Note that my whole setup is "A way of thinking" which might not fit yours (and definitely doesn't fit Arduino's core team). But the way to run commands on Linux is actually pretty simple.
This is the arduino code to launch a command on Linux:
Code: [Select]
void runShellCommand(const char * command)
{ SerialOutput->print("EXEC:");SerialOutput->println(command);};

SerialOutput is a pointer to the serial port that is connected to the yun serial port.
On my Mega yun I connected the mega serial port 2 to the yun and I get
Code: [Select]
Stream *SerialInput = &Serial2;
Stream *SerialOutput = &Serial2;


on my yun only I have
Code: [Select]
#define BridgeSerial  Serial1
.....
Stream *SerialInput = &BridgeSerial;
Stream *SerialOutput = &BridgeSerial;


I don't have a problem with modifying files on the linux part of yun. I wouldn't see why it is a problem. As I use /dev/ttyATH0 without the bridge I have to modify inittab. No way around it.

If you are (or anyone else is) still interested in the latest version of the code after reading up on the whole system let me know and I'll see what i can do.

Best regards
Jantje

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

mamu

Thx jantje!
I was just courious about if you found a way without modifying inittab.
The little problem I see while doing mods of the Linux system is that you have to remember all the mods and reapply them when you install a new image.

Go Up