Solutions for avoiding time-consuming Bridge.put and Bridge.get calls?

Hello all,

I've been working with Bridge and have been running up against a time consumption problem. I am currently running seven LED's, and each LED has two .get() (man vs auto, and on vs off) and a .put() (the status of the pin).

I did a little of my own research, and according to my not very scientific conclusions, each .get() call takes about 1.5-2 milliseconds, and each .put() call takes around 12-12.5 milliseconds.

My cycle time right now is around 125 milliseconds, and I want to add more pins, and more complexity within my sketch.

Any thoughts as to how I might avoid these delays?

Some of my self-prescribed solutions include:

*managing .get()s and .put()s so that I only use them when needed, and/or on a timer

*somehow fitting all my .put()'s into one string and sending it all at once in order to conserve .put instantiation. The only problem is that I've heard of Bridge not handling strings over 128 characters.

*maybe using File IO to manage my asynchronous communication???

If you're curious as to why I need this functionality, see my previous posts. I basically just need a website which can send asynchronous commands to my Yun, and can read pseudo real-time data from the Yun. So far I've been able to manage that with Bridge, but now I'm worried about time usage, especially when I'll need to start using analog inputs.

Thanks for all the help Yun community!

-kiobod

kiobod: Hello all,

I've been working with Bridge and have been running up against a time consumption problem. I am currently running seven LED's, and each LED has two .get() (man vs auto, and on vs off) and a .put() (the status of the pin).

I did a little of my own research, and according to my not very scientific conclusions, each .get() call takes about 1.5-2 milliseconds, and each .put() call takes around 12-12.5 milliseconds.

My cycle time right now is around 125 milliseconds, and I want to add more pins, and more complexity within my sketch.

Any thoughts as to how I might avoid these delays?

Some of my self-prescribed solutions include:

*managing .get()s and .put()s so that I only use them when needed, and/or on a timer

*somehow fitting all my .put()'s into one string and sending it all at once in order to conserve .put instantiation. The only problem is that I've heard of Bridge not handling strings over 128 characters.

If all the info you put across is simple bi-state info, you can transmit the info of up to 8 pins/LED per character/byte. That means with a string of 128 characters, you could transmit the state of up to 1024 pins/LEDs in one transmission. That's probably more than you will ever connect to a Yun... ;)

Ralf

Hadn't thought of that approach Ralf, how would I make that happen?

And would you know how to format my Bridge call so it sends all that information (at once) to end up being JSON? Or would I need to manually handle parsing.

Also would I still be able to get that info from my website do you think?

Thanks, -kiobod

how are you creating the web page?

i mean: a solution for that will be replace the bridge. bridge is very nice and very handy but a little bit slow, as you noticed.
you can do this:
write on the linux side a simple web server that in one side handle the incoming http request and in the other side read and write the serial. on the arduino side you just read and write on the serial as if you were with an arduino uno and have to communicate with your computer…

this involve commenting out the ttyATH0::askfirst:/bin/ash --login in /etc/inittab… there are few blog post about it in the net

kiobod: Hadn't thought of that approach Ralf, how would I make that happen?

And would you know how to format my Bridge call so it sends all that information (at once) to end up being JSON? Or would I need to manually handle parsing.

Also would I still be able to get that info from my website do you think?

Thanks, -kiobod

Well, programmers should solve problems not create new ones.

Yes, you would have to program on either side of the bridge some function that assembler/disassemble the bit wise information before and after the transfer as a string over the bridge. But that should be considered kind of trivial, so if you have a problem with that, please post more specifically where you are stuck and one can give you more specific hints on how to solve this.

Ralf

Wow! Thanks for the replies,

I guess building a custom bridge is the way to go then. Other than this thread: http://forum.arduino.cc/index.php?topic=191820.0 are there any resources/guides that would be helpful? I’m having trouble finding out exactly how to do this.

I’ve never done something like this before but I’m looking forward to the challenge. Thanks for the pointers, I’ll be sure to post results when I have them.

-kiobod

@mantissa,

My website currently gets from and writes to the /data/ file set up by the Bridge class. As I know more about web dev than linux, I just used /data/ to store all my asynchronous communication between my website and the ATmega in JSON. It worked great until I started using lots of .get() and .put().

Another line of inquiry I’m looking at is shoving all my .get() and .put() into one string, and then handling the parsing in the webpage, just because I know that world a little better. The custom Bridge solution would better handle the problem though.

Thanks again!