Hi all yea,

17.23 CET. Finaly we have contact!!!!

12345678
   /    1296144957195
12345678
   /    1296144957802
12345678
   /    1296144958107
12345678
   /    1296144958412
12345678
   /    1296144959018
12345678
   /    1296144959322
12345678
   /    1296144959629

data kept on comming. Now I knew there was life outthere. WE finaly had contact.

Marks mail set me thinking.
>  Well, from a quick look at things, I'd say you started a script that
> did a "repeat until EOF" and LC crashed trying to allocate memory
> space for the read. That is Not a Good Thing.

Well I didn't have a repeat loop in my code, so where could it be.
I had used read from driver "xxx" until end. I had somewhere read in the 
dictionairi to use the "until end" part for serial ports. There is on the other 
hand another form to read the driver which is like"  "for x" . Like read for 3  
(read 3 chars) or read for 1 line  etc. This gives the exact number of bytes to 
read. No loop or repeat is required. There is a specific offset, whereas the 
"until x" form most likely will use a repeat loop some where in it's code. 
probably that's the culprit. 
Well there is a bit more going on. Uptill now I have found one "mAGIc"  form 
which seems to work on OS 10.5 and 10.6 in a stable manner. This means I can 
drag the window 
around and LC still responds to clicks in the way it should,instantaniously.

step one, open the connection with: 
open driver "/dev/cu.usbmodemxxx" text for update     -- xx is the version of 
driver that was installed. 
 -- don't use binary since it will hang LC, at least it did on, I beliefe, both 
of my systems. 
 -- use update for 2 way communication.

then use a send in time form to see if there's data. As far as I know there 
isn't a serialAvailable kind of thingy so just read the serial port and see if 
you got something. Do this like:

on serialRead
   read from driver "/dev/cu.usbmodem3d11" for 1 line      -- the arduino 
scetch repeatly sends Serial.println("12345678")  with a cr with each send
   -- or 8 (chars) or something similar. [see dictionary and try at your 
personal risk]
   if it <> "" then
      -- ok we have some data. for now put it into a field. 
      put it & "   /   " & the millisecs into fld "recieved"  
   end if

   send serialRead to me in 20 
end serialRead

If you use a "until end | eof | empty" instead of read from driver 
"/dev/cu.usbmodem3d11" for 1 line 
LC will choke and in my case a hard crash.

There is a second problem solved aswell. I was able to send 1 char at a time 
with 10.5. I wasn't able to send more chars at a time.
The strange thing was I needed to send out a char before I would see anything 
returned. As soon as a char was send the input buffer 
was read and I saw suddenly quite some data in one go. This also happened when 
I send 2 or more chars from the arduino but then 
LC would hang and dye. Probably the first time the serialRead cal got invoked 
with the "until x" form something in the engine became 
a bit upset, which wasn't to bad as long as it only recieved a char at the 
time. With 2 chars at the time or worse even more, it just blew. 
It couldn't cope anymore. It just needs to get ver specific instructions 
otherwise it just spaces out on all posi bi   li    ty    's.
Anyway as I was saying, once I used the "for x" form as soon as I opend the 
driver data started streaming in like at the beginning of this mail. 
I still have to do some more testing because in my tests I also found some kind 
of intermittend forms. The data kept comming in but LC had becom unresponsif. 
I couldn't move my window around or click on buttons etc. This forced me to 
force quit. So although I haven't figured it all out yet, this seems very 
promissing 
and I will upload my test stack to revOnline as soon as I have it a bit decent. 
I hope this turns out to be a universal solution, for now at least. I believe 
these driver/file commands need a tune up. 
I guess it would be a good thing for me to do, is to add a comment in the 
dictionary

I will do some more testing but It looks like there is a workourand and we can 
all start using the fascinating world of micro conrollers.
For me this is very funny. I started out prying open / cq smashing valves as a 
young kid. Then I started playing with transistors, building 
all kinds of stuff. Then came the first logic chips. AND OR EXOR multivabrator, 
clocks, dividers. This became some kind of new lego for me. 
I could build all kinds of stuff with these building blocks. I devised my own 
cheap mans universal mega breadboard sometime in the 70's. 
It was a graet system. Take a wooden plank about 80cm X 35 cm and make a lot of 
little circuitboards which can hold one IC socked and 
have little strips of copper pointing outwards. The sockets were mounted so the 
copper would be facing up. Wherever you needed a some logic 
just screw one of these little circuit boards in the plank and solder wires to 
connected to the other ic. I made a system to sync up my film projector 
with my revox. I could just hit rewind on my revox and my filmprojector would 
start playing the film in reverse to try to catch up with my revox. 
Naturaly it always lost. The revox would start playing again and the flm would 
rewind till it found the right spot and start playing normally again. 
I had never made a schematic of it but just builded it on the go, the way my 
ideas flowed and need arose.This masive plank with all these little 
boards strewn all ove,r with some buttons and meters as a cenral block 
somewhere in the middle, wires in all colors going all over the place. 
Sometimes using a unused AND gate half way across the plank because space was 
getting at a prenium as the project unfolded and became
more complex by the week. It worked great and once I even managed to repair it 
when rehearsing for a show with dancers all dressed in white 
performing in front of a film I made. The plank, by the way that realy is the 
name that was given to this contraption I had created, refused to work 
as it should. All he dancers where there, I was there with the revox, my 
projector and my film. Just like life, sometimes things don't work. 
Well the plank certainly was broken. Looking through it's bowels I found a 
loose wire somewhere in the mesh of wires which was like a some
kind of funghis all over the plank , which obviously wasn't meant to be. I 
could deduce, and see the empty spot on the ic where it should have been. 
I didn't have any tools with me but fortunatly there was a kitchen wit a gas 
stove. I also found a very big nail, which I could heat on the stove and use 
it to weld the wire back in place. This worked out beatifully. This was really 
a, perhaps mixedup, chaotic, absolutly impossible, but beatiful and robust 
system. 
I still keep it as a trofy. It looks like with LC and the arduino I may finally 
do the stuff I used to dream of, so I better start those dreams up again.

Now with all those new lego like computer-pieces, which we can interface with 
LC, creates a really fascinating new world of possibility's.
All kind of practical 'real world' applications can be designed. The arduino is 
just one of the many new devices out there, altought the arduino 
does come with a rather  a nice IDE and a variaty of library's and hardware 
ad-ons. Beside that from what I understand, and I am just a noob,
 a clomplete freshman in this, they have a project called firmata. The goal of 
firmata is to expose all pins of the arduino to the computer 
it's connected to, without you having to program the micro conroller. As far as 
I understand this means load the frimata software on the 
arduino connect the arduino to your computer and you can acces and assign all 
pins of the arduino without programming one line
 of code on the arduino. Nice. Also really educational. You can control all 
kinds of stuff with just LC for the programming.

Please, everybody with a arduino try this and see if we can get this working on 
all systems. 

Sorry for the long mail but I guess, if you made till here, you must have kind 
of liked it. 
For me, being a long time reader and fan of this list, this seemed like a nice 
way to introduce myself a bit.

I'll keep posting my further tests and in the mean time,

Best wishes,
   Claudi









On 27 jan 2011, at 02:08, Mark Wieder wrote:

> Claudi-
> 
> Wednesday, January 26, 2011, 2:48:22 AM, you wrote:
> 
>> Thread 0 Crashed:
>> 0   libSystem.B.dylib                   0x91ddde42 __kill + 10
>> 1   libSystem.B.dylib                   0x91e5023a raise + 26
>> 2   libSystem.B.dylib                   0x91e5c622 __abort + 97
>> 3   libSystem.B.dylib                   0x91e5c68a _cproc_fork_child + 0
>> 4   libstdc++.6.dylib                   0x92049005 0x92001000 + 294917
>> 5   libstdc++.6.dylib                   0x9204710c __gxx_personality_v0 + 
>> 1108
>> 6   libstdc++.6.dylib                   0x9204714b std::terminate() + 29
>> 7   libstdc++.6.dylib                   0x92047261 __cxa_throw + 101
>> 8   libstdc++.6.dylib                   0x920475d8 operator new(unsigned 
>> long) + 100
>> 9   libstdc++.6.dylib                   0x92047689 operator new[](unsigned 
>> long) + 17
>> 10  com.runrev.livecode                 0x000a3048
>> MCExecPoint::getbuffer(unsigned int) + 56
>> 11  com.runrev.livecode                 0x00141134
>> IO_read_to_eof(IO_header*, MCExecPoint&) + 52
>> 12  com.runrev.livecode                 0x0006d3bb
>> MCRead::exec(MCExecPoint&) + 2555
>> 13  com.runrev.livecode                 0x00103a64
>> MCHandler::doscript(MCExecPoint&, unsigned short, unsigned short) +
> 
> Well, from a quick look at things, I'd say you started a script that
> did a "repeat until EOF" and LC crashed trying to allocate memory
> space for the read. That is Not a Good Thing.
> 
> -- 
> -Mark Wieder
> mwie...@ahsoftware.net
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to