Bridge and a constant serial link..

Can I use bridge to transmit data between arduino and Linux while constantly keeping a serial open to another device? Using 2 serial devices with arduino Uno wasn't possible - when another serial was opened, previous port closed.

Where is this needed? Well, I can think numerous reasons, for example; hacking and forwarding serial data from another device- possibly parsing it.. But I have a serial ttl jpeg camera for arduino. (From adafruit) and even though jpeg data is very compact when comparing to raw image data, amount of bytes in a 320x240 jpeg image- is too much for arduino to store/process atk once. Idea is that you freeze the camera, and download it's view in jpeg format in blocks, store/process the block and download next block, until full file is received - now here's the problem. If serial link is interrupted, camera needs mee initialization before you can download a block, another problem is- initialization resets camera, so you cannot resume image downloading process. I'd like to make my own wifi camera, and with arduino yun - that is going to be easy- but only if serial link isn't interrupted while transmitting data to Linux side.

Another way would be to store data to sd card, but I was not sure if provided sd is connected to arduino side or to Linux side- also, this would slow things down if you first store image data to sd and then open file from there and send it to Linux side.

And one more thing- what is the baudrate used on the bridge and can it be manipulated? Camera uses 38400, it would be nice to have fast communication with the bridge as downloading a 320x240 jpeg with 38400 and storing as blocks to sd takes about 3 seconds..

@jake1981

Usually the hint is to use SoftwareSerial, but I don't know if the library can handle a sustained speed of 38400 bps.

I see very difficult (even if theoretically possible) to make the 32U4 act as reliable and efficient proxy between the camera and the AR9331. This is further complicated because, as you already noticed, the 32U4's hardware UART is used by the Bridge, and you will face very hard timing issues if you share the serial port with both Bridge and Camera.

One possibility is to disable the 32U4 UART at all (by setting pin 0 and 1 as INPUT), connect the camera there, and let the AR9331 control the camera directly, but you lose the possibility to use the Bridge library to make the 32U4 talking with the AR9331.

Another option I can see is to extend the Bridge library, adding a command to temporarily suspend its operation and free the UART for a limited amount of time (say the time needed to download the image from the camera). In any case these are only hypothesis, you should check them on your own.

Thanks for answers- it seems it's a no go then..

Adding a hub and another kind of camera is not a good idea- I already bought 3 of these cameras, they have IR leds for night vision and packaging for outside use, so they weren't so cheap that I would give up on 'em too easily..

I thought using arduino YUN would make my system easier, but it seems I'm stuck using Maple Leafs for this (or I could use Arduino Due, it has 3 USARTs.. but maple's do the job, don't need so much space + are way cheaper..)..

And SoftwareSerial can handle 38400 atleast on UNO, but it doesn't matter, when I open up another software serial, for e.g. to send data over rs485, connection to camera is disconnected.

lock:

jake1981:
But I have a serial ttl jpeg camera for arduino.

i suggest you to add an hub to Yun to have 4 usb ports, plugging a usb-serial in one of these to interface the jtag camera. This you you could have constant streaming in and enough power to decode the jpeg on a full libraries machine!

jake1981:
Another way would be to store data to sd card

this way is easy, you just put the final jpeg image into a file, and invoke "cp file /mnt/sd-somewhere/somewhere"

Actually, this might be a solution.. Didn't understood what you meant first, since you talked about jtag camera instead of serial jpeg camera.. If I don't add more devices- why a hub? For powering up? Camera is powered up by different power lines..

Just ordered a Yun-- and a USB-TTL 3.3v/5v convertor based on PL2303HX..

You just keep talking about jtag camera.. I have 3 of these: Weatherproof TTL Serial JPEG Camera with NTSC Video and IR LEDs : ID 613 : $54.95 : Adafruit Industries, Unique & fun DIY electronics and kits
Might be that you found something better, but since I've already invested to these it's unlikely that I go the other way..
But because of the curiosity.. I might wanna have a look at the cameras you found too.. Got a url to your findings..?

If Linux drivers exists- this should not be a problem as linino is heavily based on openwrt, a long time ago I added support for ms laptop webcam on my openwrt driven linksys nslu2.. Then made a script that took a picture and export it to web- so when ever I opened that page, it took a picture and displayed it on my browser. Also added auto update on that page later, so it streamed with 1fps..

And this was not hard- so if the kernel drivers are there, it's not that hard..

If you choose to connect a consumer usb webcam to the USB-A port of the Yun I suggest you to take a look to this page. OpenWRT website has a really good documentation pages, in this case is a good starting point to know which webcams are supported and there are also examples of software you can use to take pictures or video.

And if you want to add support for not currently by openwrt supported device- check out gentoo's ebuilds, most of them are relatively easy to concert to openwrt packages..