?

Log in

No account? Create an account

<3 PLT - Teflon® Weltanschauung

Jul. 4th, 2010

10:02 pm - <3 PLT

Previous Entry Share Next Entry

Another programming milestone passed.

We have an instrument at work, our most popular one, that requires some extensive testing. And then we're developing another one based on the same technology that also requires testing. Our one—one!—programmer simply cannot keep up with his demands and implement the changes I'd like to get some automated testing done.

Well, score one for the PLT group, previously makers of PLT Scheme, now "Racket." (Not sure about the name but whatever.) They have a foreign function interface that is so magical I get a little giddy just thinking about it. I got access to the DLL for our prototype, which also works for our main instrument, and in three days banged out about 16 pages of scheme (ok, ok, Racket) to control it, and get just the data that I want the way I want.

The lovely thing? Apart from a minor control issue (not worth going into details), the code worked perfectly the first time, every time. I always had the possibility of hacking our C++ code, but shuddered at the thought. Better to live with the heartache of manual experiments than muck around in C++. But this week I told myself, "Time to try the FFI," and wham—a functional script. It already generated data I literally could not have collected previously because the C++ code for the prototype is such a hack and doesn't work.

I don't understand why anyone uses C++ for anything. Python, Lua, Lisp, and probably every other decent language in existence is capable of dealing with C code. If you need to get down to the metal, write up some libraries in C. I just don't understand the point of wasting programming time on managing C++ garbage.

Well, anyway, yay! All I need to work on now is some kind of interface to serial ports (maybe possible directly in Racket) and I will be able to have a completely automated testing script. Plug it in, turn it on, and click the button. So awesome.

Comments:

[User Picture]
From:elibarzilay
Date:July 5th, 2010 04:09 am (UTC)

Serial port access

(Link)
Ask on the Racket mailing list -- IIRC, there were several people who had implemented a serial port interface.
(Reply) (Thread)
[User Picture]
From:erislover
Date:July 5th, 2010 08:18 pm (UTC)

Re: Serial port access

(Link)
Thanks, Eli. From looking at some old posts on the mailing list it looks like I can just create a file port directly (probably assuming the default settings for the port are correctly set up in the device manager). The device I need to communicate with doesn't return any useful information, so I don't need to both read and write.

And, yeah, thanks for your work on a wonderful distribution. Racket is really great.
(Reply) (Parent) (Thread)
[User Picture]
From:elibarzilay
Date:July 5th, 2010 09:28 pm (UTC)

Re: Serial port access

(Link)
Well, if all you need is simple writing to the port, then yes, it'll be easy (probably on both unix and windows). IIUC, the fun begins when you need to control the low-level features of the serial line.
(Reply) (Parent) (Thread)
From:mazupawl
Date:April 13th, 2011 06:55 am (UTC)
(Link)
Please, can you PM me and tell me number of much more thinks about this, I am truly fan of one’s webpage…gets solved properly asap.

(Reply) (Thread)
From:gofuhame
Date:April 13th, 2011 09:40 pm (UTC)
(Link)
Thanks for your share! very impressive!

(Reply) (Thread)