OpenPCR + Terminal: Any leads?

123 views
Skip to first unread message

Cathal Garvey

unread,
Mar 22, 2012, 9:10:31 AM3/22/12
to DIYbio List
Hey all,
Of those who own and love their OpenPCR, has anyone tried using Terminal
to send programs over the wire, or to get real-time output from the machine?

I'm running Ubuntu, and I'm wondering if I can use echo and/or cat with
piping to send commands directly to the device (which is currently
/dev/sde, mounted as /media/OPENPCR).

The end goal would be to translate this totally manual approach into a
python script, perhaps with a GUI to match eventually, as a way to
replace the Adobe Air interface. Although I got the Air interface
working with Tito and Josh's help, really the problem isn't going away;
shortly before release of the OpenPCR, Adobe cut support for Air in Linux.

Would be nice to have an Open Source language working for my Open Source
PCR machine. :)

--
www.indiebiotech.com
twitter.com/onetruecathal
joindiaspora.com/u/cathalgarvey
PGP Public Key: http://bit.ly/CathalGKey

Nathan McCorkle

unread,
Mar 22, 2012, 11:46:39 AM3/22/12
to diy...@googlegroups.com
I don't have an OpenPCR, so I can't test exactly... but I think strace
might work (I posted the problem to the blktrace group, and they
responded saying blktrace doesn't dump the actual data)

strace -e trace=write ../path/to/openPCRapplication

If that doesn't show the actual data being written, it might be
another strace option

> --
> You received this message because you are subscribed to the Google Groups "DIYbio" group.
> To post to this group, send email to diy...@googlegroups.com.
> To unsubscribe from this group, send email to diybio+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/diybio?hl=en.
>

--
Nathan McCorkle
Rochester Institute of Technology
College of Science, Biotechnology/Bioinformatics

Bryan Bishop

unread,
Mar 22, 2012, 12:07:24 PM3/22/12
to diy...@googlegroups.com, Cathal Garvey, Bryan Bishop
On Thu, Mar 22, 2012 at 8:10 AM, Cathal Garvey wrote:
I'm running Ubuntu, and I'm wondering if I can use echo and/or cat with
piping to send commands directly to the device (which is currently
/dev/sde, mounted as /media/OPENPCR).

you can just send bytes down like the program expects:
https://github.com/jperfetto/OpenPCR/blob/master/arduino/OpenPCR/serialcontrol.cpp

and here are the command bytes:

I sort of doubt that the device is mounted as /dev/sde or /media... that's pretty unusual for something that you're not using as storage.

P.S. HOLY HELL why are the build instructions 100000 MB? what the fuck guys
and no, hosting on scribd is not a reasonable solution..

- Bryan
http://heybryan.org/
1 512 203 0507

Nathan McCorkle

unread,
Mar 22, 2012, 12:18:53 PM3/22/12
to diy...@googlegroups.com
I'm pretty sure, from the talks I had with Josh and Tito, that a fake
file on a 'disk drive' was chosen to read/write from to get around
having to install serial port drivers on different platforms. Not
really sure why, since FTDI has royalty-free drivers for most/all
platforms.

Cathal Garvey

unread,
Mar 22, 2012, 12:51:32 PM3/22/12
to diy...@googlegroups.com
Ah, so you send the bytes to a file on the "OPENPCR" storage device,
rather than directly to OpenPCR? Treat the file as if it's the OpenPCR
device?

Bryan: If it didn't make an entry in /dev/, how would you interact with
it? Honest n00b question here; I thought everything connected to Linux
made a /dev/ entry to represent the device as a file?


--

Bryan Bishop

unread,
Mar 22, 2012, 1:07:27 PM3/22/12
to diy...@googlegroups.com, Cathal Garvey, Bryan Bishop
On Thu, Mar 22, 2012 at 11:51 AM, Cathal Garvey <cathal...@gmail.com> wrote:
Ah, so you send the bytes to a file on the "OPENPCR" storage device,
rather than directly to OpenPCR? Treat the file as if it's the OpenPCR
device?

Don't know, haven't found where in their source they are reading from.
 
Bryan: If it didn't make an entry in /dev/, how would you interact with

No, an entry on /dev is perfectly fine... /dev/sde usually means a file storage device. I was unaware that this is how OpenPCR operates. It's unusual. Another /dev entry would have been reasonable, if there was some custom driver; or maybe if it was on a serial port it would be one of the /dev devices devoted to uh.. the serial ports. Which are definitely not /dev/sd* or named similarly.
 
it? Honest n00b question here; I thought everything connected to Linux
made a /dev/ entry to represent the device as a file?

yes

Avery louie

unread,
Mar 22, 2012, 1:11:58 PM3/22/12
to diy...@googlegroups.com
Is it USB based?

--A

On Thu, Mar 22, 2012 at 12:07 PM, Bryan Bishop <kan...@gmail.com> wrote:

Cathal Garvey

unread,
Mar 22, 2012, 1:17:55 PM3/22/12
to diy...@googlegroups.com
Yup. Arduino UNO with a custom driver board and totally replaced
firmware (i.e. no Arduino bootloader).

Thanks for that detail Bryan.
So, I take it that if I format a program correctly, I should echo
'<program' > /media/OPENPCR/some_file to upload it? I recall from
private conversations with Tito & Josh that there's a particular
formatting thing in the program that says "start immediately", and
another program syntax for "stop", so the above syntax (if correct)
would allow most routine operations.

As to getting info back out, I gather that the ncc program (standing for
"No Cache Cat") can be used like "cat" to get a feed of information from
another output file on /media/OPENPCR/. But for now, I just want a quick
way to program it without Adobe Air: I'd settle for having no output
initially.

Nathan McCorkle

unread,
Mar 22, 2012, 1:23:36 PM3/22/12
to diy...@googlegroups.com
try the strace command earlier, and just watch what the Air program
'writes' to the OpenPCR (you can change the -e trace=read to look at
what the Air program 'reads' from the 'file)

Its likely that what's written doesn't get 'saved' such that you can
later cat or open it... that said, once OpenPCR replies the reply is
probably only readable until the next command is sent from the Air
program

--

Cathal Garvey

unread,
Mar 22, 2012, 1:48:12 PM3/22/12
to diy...@googlegroups.com
Hm. Typing "strace -e trace=write /opt/OpenPCR/bin/OpenPCR" yields only
the following:
--- SIGCHLD (Child exited) @ 0 (0) ---
--- SIGCHLD (Child exited) @ 0 (0) ---
--- SIGCHLD (Child exited) @ 0 (0) ---
--- SIGCHLD (Child exited) @ 0 (0) ---
--- SIGCHLD (Child exited) @ 0 (0) ---
--- SIGCHLD (Child exited) @ 0 (0) ---

Glancing at the man-files for strace suggests that it actually
calls/executes the program you specify, which probably isn't compatible
with an Air app.

How would one hax strace to monitor an existing process? It opens a
process named "OpenPCR", you can get the process ID with "pidof OpenPCR".

Cathal Garvey

unread,
Mar 22, 2012, 1:54:51 PM3/22/12
to diy...@googlegroups.com
Wait: I have it.
I ran:
"sudo strace -o strace_openpcr_writes -e trace=write -p 312"
The "-p 312" part is the process ID of the running OpenPCR app, which I
got with "pidof OpenPCR" (equally could use "top" to see all running
processes and look for OpenPCR..).

The results looked like this (comments with hashes are mine, original
file is attached):

===============================================
### Lots of SIGCHLD crap

--- SIGCHLD (Child exited) @ 0 (0) ---

write(19, "B", 1) = 1
write(123, "s=ACGTC&c=start&t=50&d=22479&l=9"..., 157) = 157 # Here I
sent a program to the machine and it started. The complete program isn't
shown in this output data sadly.


--- SIGCHLD (Child exited) @ 0 (0) ---

write(19, "B", 1) = 1

###(more SIGCHLD crap)

--- SIGCHLD (Child exited) @ 0 (0) ---

write(19, "B", 1) = 1
write(11, "s=ACGTC&c=stop&t=50&d=22480", 27) = 27 # Here I clicked
"stop" in the OpenPCR app.


--- SIGCHLD (Child exited) @ 0 (0) ---

write(19, "B", 1) = 1

###(more SIGCHLD crap)
===============================================

On 22/03/12 15:46, Nathan McCorkle wrote:

strace_openpcr_writes

Bryan Bishop

unread,
Mar 22, 2012, 1:56:33 PM3/22/12
to diy...@googlegroups.com, Bryan Bishop, Cathal Garvey
On Thu, Mar 22, 2012 at 12:54 PM, Cathal Garvey <cathal...@gmail.com> wrote:
--- SIGCHLD (Child exited) @ 0 (0) ---
write(19, "B", 1)                       = 1
write(11, "s=ACGTC&c=stop&t=50&d=22480", 27) = 27       # Here I clicked
"stop" in the OpenPCR app.
--- SIGCHLD (Child exited) @ 0 (0) ---
write(19, "B", 1)                       = 1

yes but what file handler is being used here? Could you just recompile the openpcr software and spit out the filenames?

Cathal Garvey

unread,
Mar 22, 2012, 2:06:37 PM3/22/12
to DIYbio List
OK cool, so using the strace info (thanks Nathan!) and directing stuff
with hard-quoted (' rather than ") echo commands to the "CONTROL.TXT"
file in /media/OPENPCR, I got it to start a program and stop a program.

It's probable that last time I tried this and failed (ruling it out as a
possibility thereby), it failed merely because I was using the wrong
quotation mark: " only ignores spaces, but special characters like
slashes etc. still screw it up, whereas ' sends the literal enclosed
string without interference.

So, here's what I sent and had success with:
To start:
paragon@Tranquillity:~ echo -n
's=ACGTC&c=start&t=50&d=55709&l=96&n=IndieBB MCS
Check&p=(1[75|95|Initial
Step])(40[20|95|Step][10|60|Step][32|70|Step])(1[120|70|Final
Step][0|4|Final Hold])' > /media/OPENPCR/CONTROL.TXT

To stop:
paragon@Tranquillity:~ echo -n 's=ACGTC&c=stop&t=50&d=55710' >
/media/OPENPCR/CONTROL.TXT

The program syntax can be deciphered from the first command.
All commands start with 's=ACGTC'.
The '&c=start' part says to start with the ensuing program.
Not sure what '&t=50' or '&d=55709' mean.
'&l=96' means set lid to 96C.
'&n=IndieBB MCS Check' means set the displayed name to "IndieBB MCS Check".
'&p=(<Initial>)(<Cycle>)(<End>)' is the program itself.

Mac Cowell

unread,
Mar 22, 2012, 2:17:01 PM3/22/12
to diy...@googlegroups.com, DIYbio List, Chris Templeman
use strace to watch a file that's named something like
/opt/OpenPCR/bin/OpenPCR/STATUS.TXT

This is a great thread, I have a similar interest in understanding and using a "standard" API for PCR machines, the OpenPCR approach seems like it has the basis of some good first practices, like articulating thermocycling programs in yaml etc.

Mac

231.313.9062 // @100ideas // sent from my rotary phone

Josh Perfetto

unread,
Mar 22, 2012, 2:21:26 PM3/22/12
to diy...@googlegroups.com
On Thu, Mar 22, 2012 at 11:06 AM, Cathal Garvey <cathal...@gmail.com> wrote:
Not sure what '&t=50' or '&d=55709' mean.

d= is a command counter. t= isn't used on the latest machines, but I believe used to indicate contrast. Now o= indicates contrast.

When you read STATUS.TXT, the OS will cache it by default (making subsequent checks useless). If you want to avoid this, there is a program "ncc" bundled with the air app. ncc = no cache cat, and works like cat. You can use this to read the STATUS.TXT w/o caching.

-Josh

Josh Perfetto

unread,
Mar 22, 2012, 2:30:24 PM3/22/12
to diy...@googlegroups.com
On Thu, Mar 22, 2012 at 9:18 AM, Nathan McCorkle <nmz...@gmail.com> wrote:
I'm pretty sure, from the talks I had with Josh and Tito, that a fake
file on a 'disk drive' was chosen to read/write from to get around
having to install serial port drivers on different platforms. Not
really sure why, since FTDI has royalty-free drivers for most/all
platforms.

Yup. We didn't want users to have to configure serial ports which can be quite a pain, especially for non-techie issues. We also didn't want to deal with accessing serial ports in a platform-independent manner (the AIR platform doesn't help), nor did we want to write and distribute our own OpenPCR USB driver on multiple platforms. So we chose this hack instead :) The only thing I don't like is we couldn't get Windows to stop opening an explorer window when you plug it in.

-Josh

Nathan McCorkle

unread,
Mar 22, 2012, 5:05:53 PM3/22/12
to diy...@googlegroups.com
On Thu, Mar 22, 2012 at 2:21 PM, Josh Perfetto <jo...@snowrise.com> wrote:
> On Thu, Mar 22, 2012 at 11:06 AM, Cathal Garvey <cathal...@gmail.com>
> wrote:
>>
>> Not sure what '&t=50' or '&d=55709' mean.
>
>
> d= is a command counter. t= isn't used on the latest machines, but I believe
> used to indicate contrast. Now o= indicates contrast.

d is just a usage statistic then? what does 'contrast' do (ramp
rate?), or PID controller stuff?

>
> When you read STATUS.TXT, the OS will cache it by default (making subsequent
> checks useless). If you want to avoid this, there is a program "ncc" bundled
> with the air app. ncc = no cache cat, and works like cat. You can use this
> to read the STATUS.TXT w/o caching.
>
> -Josh
>

> --
> You received this message because you are subscribed to the Google Groups
> "DIYbio" group.
> To post to this group, send email to diy...@googlegroups.com.
> To unsubscribe from this group, send email to
> diybio+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/diybio?hl=en.

--

Cathal Garvey

unread,
Mar 22, 2012, 5:17:20 PM3/22/12
to diy...@googlegroups.com
I imagine that's "display contrast", but I've like to heart what d does, too?

Nathan McCorkle <nmz...@gmail.com> wrote:

--
Sent from K-9 Mail on Android

Josh Perfetto

unread,
Mar 22, 2012, 5:59:41 PM3/22/12
to diy...@googlegroups.com
Yes it was display contrast. d= is used to properly acknowledge commands in the STATUS.TXT. I.e. if you send a start command in the command file, you need to read the status.txt to make sure it got started. So you look at the status.txt to see the state of the machine, but status.txt will also echo back the d= sent to it in the command file. That way you know the machine has received and processed your last command.

This is important in a situation where say the pcr machine is running program A (so state is running/heating etc). The protocol allows you to start program B without first stopping it (so the state will still be running). The d= lets you know if your new command was run. It also de-dupes some messages.

Just set it randomly, increment it by 1 for each command and wrap it at 65536.

-Josh

Cathal Garvey

unread,
Mar 22, 2012, 6:52:33 PM3/22/12
to diy...@googlegroups.com
Cool, thanks! Is it mandatory, or can you omit it? I'm thinking of the
minimal set of variables that need to be set; tweetable programs would
ideally be short enough to leave some commenting room! :)

Josh Perfetto

unread,
Mar 22, 2012, 6:57:15 PM3/22/12
to diy...@googlegroups.com
I think it may work without it if you don't care about reading the status accurately but didn't check. The format of the command string is pretty condensed due to memory constraints.

-Josh

Cathal Garvey

unread,
Mar 22, 2012, 6:58:29 PM3/22/12
to diy...@googlegroups.com
Question on dealing with this setup from within something like Python;
how is OpenPCR actually reading the file? Does it poll the file
regularly? Would a lock on the file break this system?

I ask because Python seems to support streaming in/out, but doesn't seem
to have a builtin system for just "dumping" a value on a file in one-go
like echo does.

Of course, echo might be a stream-based system too; anyone to weigh in
on this? If I use a stream object from within python to write a program
to CONTROL.TXT, will that work? It looks like I could use the
"io.FileIO" object detailed here:
http://docs.python.org/dev/library/io.html - in write mode, I think it
overwrites the file every time?

Nathan McCorkle

unread,
Mar 22, 2012, 8:16:36 PM3/22/12
to diy...@googlegroups.com
On Thu, Mar 22, 2012 at 2:06 PM, Cathal Garvey <cathal...@gmail.com> wrote:
> OK cool, so using the strace info (thanks Nathan!) and directing stuff
> with hard-quoted (' rather than ") echo commands to the "CONTROL.TXT"
> file in /media/OPENPCR, I got it to start a program and stop a program.

Cool!

I spent the last few hours looking into easy GUI options, and this
looks like the easiest way, but hard to get data in and out of the
GUI-land:
http://pysnippet.blogspot.com/2010/01/calling-python-from-javascript-in-pyqts.html

P.S. that code should work with out-of-the-box Ubuntu

Bryan Bishop

unread,
Mar 22, 2012, 8:25:13 PM3/22/12
to diy...@googlegroups.com, Nathan McCorkle, Bryan Bishop
On Thu, Mar 22, 2012 at 7:16 PM, Nathan McCorkle <nmz...@gmail.com> wrote:
I spent the last few hours looking into easy GUI options, and this
looks like the easiest way, but hard to get data in and out of the
GUI-land:
http://pysnippet.blogspot.com/2010/01/calling-python-from-javascript-in-pyqts.html

That's what I use for some of my web scraping, actually. That and phantomjs.org.

Josh Perfetto

unread,
Mar 23, 2012, 1:25:45 AM3/23/12
to diy...@googlegroups.com
OpenPCR doesn't poll the control file. The control file really doesn't exist. When the USB mass storage file system SCSI command comes in and writes to the FAT block that represents the file, the command (embedded in the FAT block) is simply passed on the Atmega328, rather than be written to flash. I can't speak to the python programming question, but think as long as you open a file for write, write it quickly, and close it, it should work. The file is very tiny.

-Josh


Cathal Garvey

unread,
Mar 24, 2012, 6:46:39 PM3/24/12
to DIYbio List
So, I just tested quickly whether python works well. The following
worked just fine after plugging in and turning on my OpenPCR. NB: There
was no "CONTROL.TXT" file initially, because the OpenPCR hadn't been
sent one yet.

1) I cd'd to /media/OPENPCR
2) I opened python3 from terminal
3) I typed the following code, which worked nicely:
controlfile = open("CONTROL.TXT", "wt")
controlfile.write("s=ACGTC&c=start&t=50&d=55709&l=96&n=IndieBB MCS


Check&p=(1[75|95|Initial
Step])(40[20|95|Step][10|60|Step][32|70|Step])(1[120|70|Final

Step][0|4|Final Hold])")
controlfile.close()

The OpenPCR started running my program right away. :)

So, now I just need to hack up a set of scripts for sending the program
to the OpenPCR, and for making the program using friendly user input.
Can later bake a GUI on top of that stuff.

On 22/03/12 13:10, Cathal Garvey wrote:

Petfixer71

unread,
Mar 25, 2012, 9:49:54 AM3/25/12
to diy...@googlegroups.com
I plan on ordering an OpenPCR device in the next week or two.   I have heard rumors that there is a 4-6 week lag time after placing the order and receiving the unit??   My only other reluctance is the setup and how "user friendly" the unit is??  After reading this thread I am a bit intimidated?  Do I need to be a computer programer to get this up and running?\

Need feedback?

Cathal Garvey

unread,
Mar 25, 2012, 9:59:36 AM3/25/12
to diy...@googlegroups.com
God no, after assembly it's the easiest thing in the world to use! I just don't like Adobe Air, and it's poorly supported in Linux.

This thread is all about me being picky. OpenPCR is awesome and very user friendly. Well worth paying and waiting for! :)

Petfixer71 <afris...@hotmail.com> wrote:

><http://joindiaspora.com/u/cathalgarvey>


>> PGP Public Key: http://bit.ly/CathalGKey
>>
>>
>

>--
>You received this message because you are subscribed to the Google
>Groups "DIYbio" group.

>To view this discussion on the web visit
>https://groups.google.com/d/msg/diybio/-/3yBmlI_hUyIJ.


>To post to this group, send email to diy...@googlegroups.com.
>To unsubscribe from this group, send email to
>diybio+un...@googlegroups.com.
>For more options, visit this group at
>http://groups.google.com/group/diybio?hl=en.

--

John Griessen

unread,
Mar 25, 2012, 10:53:08 AM3/25/12
to diy...@googlegroups.com
On 03/24/2012 05:46 PM, Cathal Garvey wrote:
> So, now I just need to hack up a set of scripts for sending the program
> to the OpenPCR, and for making the program using friendly user input.
> Can later bake a GUI on top of that stuff.

Will you be able to easily fold your changes into the docs for OpenPCR?
Sounds great to me -- I use debian and ubuntu linux at my desk and on
the lab bench.

John

Josh Perfetto

unread,
Mar 26, 2012, 1:35:58 AM3/26/12
to diy...@googlegroups.com
Awesome :) BTW it was always the intention that the GUI would let you name the steps like "Denaturing" instead of just "Step" but we never got to it with our AIR app. So if you change the text in the program string it should display it on the LCD.

-Josh


--
You received this message because you are subscribed to the Google Groups "DIYbio" group.
Reply all
Reply to author
Forward
0 new messages