Kjetil's Information Center: A Blog About My Projects


A follow-up on my previous articles about a GR-KURUMI Writer and the GR-KURUMI Makefiles. Here is a program written for the GR-KURUMI that provides a command shell interface against its LED and timer functions.

The shell is spawned on UART #0, the same one used for flashing, since this is most convenient. The DTR signal must be disconnected in order to avoid the chip going into flashing mode though. The shell provides a simple BASIC-style scripting interface. Commands can be put into a script/program buffer, indexed by 0 to 99, which can be run continuously.

Get the source code here and check the article on Makefiles on how to get the tool chain up and running. Then use the article on the Writer to flash the chip.

Here is a Python script that can be used to load script files remotely in an easy manner:


import serial

class Kurumi(object):
    def __init__(self, port):
        self.s = serial.Serial()
        self.s.port = port
        self.s.baudrate = 9600
        self.s.bytesize = serial.EIGHTBITS
        self.s.parity = serial.PARITY_NONE
        self.s.stopbits = serial.STOPBITS_ONE
        self.s.xonxoff = False
        self.s.rtscts = False
        self.s.dsrdtr = False

    def __del__(self):

    def _command(self, cmd):
        print ">", cmd
        for char in cmd:
            self.s.write(char) # Write one character at a time...
            self.s.read(1)     # ...and read the echo.
        self.s.write("\r") # Finish command...
        self.s.read(10)    # ...and read the prompt.

    def script(self, filename):
        self._command("red off")
        self._command("green off")
        self._command("blue off")
        with open(filename) as fh:
            for line_no, line in enumerate(fh):
                self._command("%s %s" % (line_no, line.strip()))

if __name__ == "__main__":
    import sys
    k = Kurumi("/dev/ttyUSB0")

    if len(sys.argv) > 1:
        print "Usage: %s <script file>" % (sys.argv[0])

A typical script file can look like this:

red on
sleep 50
red off
sleep 50
green on
blue on
sleep 100
green off
sleep 100
blue off
sleep 500

Topic: Open Source, by Kjetil @ 25/11-2017, Article Link