Go Down

Topic: Yun - Using PHP to get a value from sketch (Read 491 times) previous topic - next topic

arjan_hes

Hi,

I see many examples of a PHP scripts reading values from digital or analog pins. Is it also possible to get, for example, the value of 'myValue' which is incremented by an interrupt?

Ideally, 'myValue' should be reset to 0 as soon as I have the value in the php side of things. Reason I try to avoid using the sketch for this is: what if the sketch is halfway in processing the value and an interrupt occurs? Then everything goes pearshaped right?

Ideas, hints, tips, tricks and examples welcome!

PaulS

Quote
Reason I try to avoid using the sketch for this is: what if the sketch is halfway in processing the value and an interrupt occurs?
If you think that somehow PHP is going to be able to access the variable in some magic way that the sketch can't, I'd like some of what you've been smoking.

You can ensure that an interrupt doesn't happen while you are copying or resetting a multi-byte variable by putting noInterrupts() just before, and interrupts() just after, the code to copy or reset the variable. Make those two calls as close together as possible, so interrupts are disabled for as short a time as possible.
The art of getting good answers lies in asking good questions.

arjan_hes

noInterrupts() and interrupts() it is then...

I was hoping that, instead of the sketch needs to make contact with the linux side etc or even directly insert values into mysql what could possibly take a few seconds, a call from the Linux side would be handled in under a second. Reason for using php is just I am familiair with it and have next to none python experiance...

Go Up