Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(37)  |  Call(19)  |  Derive(0)  |  Import(18)
Build a command string that can be sent to the arduino.

Input:
    cmd (str): the command to send to the arduino, must not
        contain a % character
    args (iterable): the arguments to send to the command

@TODO: a strategy is needed to escape % characters in the args

        def build_cmd_str(cmd, args=None):
    """
    Build a command string that can be sent to the arduino.

    Input:
        cmd (str): the command to send to the arduino, must not
            contain a % character
        args (iterable): the arguments to send to the command

    @TODO: a strategy is needed to escape % characters in the args
    """
    if args:
        args = '%'.join(map(str, args))
    else:
        args = ''
    return "@{cmd}%{args}$!".format(cmd=cmd, args=args)
        


src/p/y/Python-Arduino-Command-API-HEAD/tests/test_arduino.py   Python-Arduino-Command-API(Download)
    def test_version(self):
        from Arduino.arduino import build_cmd_str
        expected_version = "version"
        self.mock_serial.push_line(expected_version)
        self.assertEquals(self.board.version(), expected_version)
        self.assertEquals(self.mock_serial.output[0], build_cmd_str('version'))
 
    def test_pinMode_input(self):
        from Arduino.arduino import build_cmd_str
        self.board.pinMode(pin, INPUT)
        self.assertEquals(self.mock_serial.output[0],
            build_cmd_str('pm', (-pin,)))
 
    def test_pinMode_output(self):
        from Arduino.arduino import build_cmd_str