Can two handlers access a variable at the same time?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 919
- Joined: Wed Nov 04, 2009 11:41 am
Can two handlers access a variable at the same time?
The Background : I am attempting to read and process data received on a serial port at 4800 baud. I can read the port o.k. and display the lines of data in a field but when I attempt to process the data in someway the time it takes to process means that I either miss messages or start to lag behind.
My attempt at a solution involves writing the line of data to a local variable and then accessing the variable from inside a second handler. Both my port reading handler and the variable reading handler recall themselves after 10 ticks. The only processing I have attempted so far is to display the line of data in a field. The problem is that the lines seem to get corrupted and I was wondering if my variable is being worked on by both the handlers at the same time and that this is causing the corruption.
I have posted similar questions under a couple of serial port threads but as yet no one has offered any answers. I'm hoping that by rephrasing the question some one may notice it.
Thanks for reading
My attempt at a solution involves writing the line of data to a local variable and then accessing the variable from inside a second handler. Both my port reading handler and the variable reading handler recall themselves after 10 ticks. The only processing I have attempted so far is to display the line of data in a field. The problem is that the lines seem to get corrupted and I was wondering if my variable is being worked on by both the handlers at the same time and that this is causing the corruption.
I have posted similar questions under a couple of serial port threads but as yet no one has offered any answers. I'm hoping that by rephrasing the question some one may notice it.
Thanks for reading
best wishes
Skids
Skids
Re: Can two handlers access a variable at the same time?
Hi Simon,
I believe you should post your scripts. What you describe should be possible.
Best,
Mark
I believe you should post your scripts. What you describe should be possible.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 919
- Joined: Wed Nov 04, 2009 11:41 am
Re: Can two handlers access a variable at the same time?
Hi Mark,
Thanks for your reply. I (with much help from the forum) solved the initial problem by changing how I read data from the port. My project has changed from reading data from a GPS to reading data from a hall sensor. It is now nearing completion and when finished I propose to write it up as a demonstration of what is possible for a new user to achieve using RunRev and an interface card like Arduino.
best wishes
Simon
Thanks for your reply. I (with much help from the forum) solved the initial problem by changing how I read data from the port. My project has changed from reading data from a GPS to reading data from a hall sensor. It is now nearing completion and when finished I propose to write it up as a demonstration of what is possible for a new user to achieve using RunRev and an interface card like Arduino.
best wishes
Simon
best wishes
Skids
Skids
Re: Can two handlers access a variable at the same time?
Simon,
as Mark pointed out it is difficult to tell what is going on without more detail. The relevant parts of the script would be helpful. What if you'd copy the variable after the reading is done to another variable for access by the second routine. If the two routines interleave and act on the data some sort of confusion seems possible.
regards
Bernd
as Mark pointed out it is difficult to tell what is going on without more detail. The relevant parts of the script would be helpful. What if you'd copy the variable after the reading is done to another variable for access by the second routine. If the two routines interleave and act on the data some sort of confusion seems possible.
regards
Bernd
-
- Posts: 919
- Joined: Wed Nov 04, 2009 11:41 am
Re: Can two handlers access a variable at the same time?
Thanks for your help. My original post is quite old (beginning of Feb) and you have already helped me solve the problem which was covered in another series of posts. I do intend publishing my code but in the form of a report that describes the creation of my "approximator" which involves interfacing with an Arduino card and driving a home brew display of 7 LEDs based on reading obtained from a magnetic speed sensor fitted to a speedo cable. My device is being fielded next weekend in a historic car rally taking place in Spain next weekend, which is where I will find out if my soldering will hold up to the vibration. The two pictures show the device and its contents in prototype form. The pencil is pointing at the hall effect sensor.
I would like to thank you and the other members of the forum for all the help and encouragement that I have had since joining last Autumn .
best wishes
Simon
best wishes
Skids
Skids
Re: Can two handlers access a variable at the same time?
Hi Simon,
That looks very cool and I am realy curious about what you can tell us about your hardware interfacing adventure.
I like your mug, btw.
Mark
That looks very cool and I am realy curious about what you can tell us about your hardware interfacing adventure.
I like your mug, btw.
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode