Go Down

Topic: Bridge.put() / Bridge.get() alternative (Read 539 times) previous topic - next topic

vulture2600

Does anyone know of any basic examples of how to pass data to and from the bridge keystore without using put() or get()?

Id like to avoid using Strings.

I dont know any python yet but I may be able to piece it together if there was a solid example that shows how to put and get from the arduino side and put and get from a website.

Thanks!
"Wise man says forgiveness is divine, but never pay full price for late pizza." - TMNT

ShapeShifter

What is your ultimate goal?

It's common for a person to have a goal, and start figuring out the steps to solving that goal. In the process, they get stuck on a particular step, and ask for help in solving that one step. The problem there is that by focusing on that step, you lose sight of the goal, and there may be better paths to that goal which don't involve that problematical step.

In my experience, the Bridge keystore has some significant limitations, which make it a poor choice for many applications. Being restricted to strings is not one of those limitations, at least in my mind. Yes, the keystore is easy to use, which is its main appeal. But in all of my Yun projects, I've always found a better alternative.

So, what are you trying to actually accomplish? It's quite likely that the Bridge keystore is not the most appropriate way to do it, so it may not be worth the effort to come up with the work-around that you seek.

vulture2600

I'm writing several different pieces of data to the keystore at irregular intervals that are then fetched by the web page, parsed and displayed. Commands are sent from the web page as a single char and read with Bridge.get() each time thru the loop. When a non-"0" character is read, it is executed and then overwritten with a zero.

Are there any better ways to do this? I like the idea of the linux side doing all the web page serving.
"Wise man says forgiveness is divine, but never pay full price for late pizza." - TMNT

ShapeShifter

One of the serious limitations of the Bridge keystore is that there is no notification of written values - when your sketch reads from it, you have to check for changed values, as you are doing now. But the problem is that if two values are written before the sketch has a chance to read the first one, the first one is lost. And there is a potential race condition with your scheme to clear out a written value: if a new value is written after you read the previous value and before you clear the value, that latest value will be lost. While the window of opportunity for a problem is short, it is not zero.

In your first post, you are concerned about using strings. Is that because you don't want to use the String class, or because you want to store binary data? If the latter, that doesn't really make sense as the value would be converted to a string when it gets sent in the data get web request - it needs to be made a string at some point.

The Bridge keystore is easy use, but it has some disadvantages. These include the issues mentioned above, as well as speed and other issues. I used it at first, but now avoid it. Unfortunately, while there are some alternatives that are higher performance and more powerful, they involve programming on the Linux side. In my Yun projects, I try to make the Sketch as simple as possible, and do as much processing on the Linux side as well. But there is a definite learning curve involved.

Go Up