OP-BTS Device Script Interpreter Programming Guide

Syntax support

Support for a subset of python3 standard syntax.

Module API documentation.

Opbt Device Control

class device

  • SetOutputMode: Sets the output device for script display.
  • GetOutputMode: Gets the current output device for display.
  • TransparentModeOn: Enter data transparent transmission mode.
  • TransparentModeOff: Exit data transparent transmission mode.
  • IecAutoOn: IEC automatic baud rate enable.
  • IecAutoOff: IEC automatic baud rate disable.
  • UartConfig: Serial port parameter configuration.
  • UartSendByte: Send a byte to the serial port.
  • UartGetByte: Receive a byte from the serial port.
  • UartSendString: Send a string via the serial port.
  • UartSendStringNoWait: Send a string via the serial port(no wait).
  • LedSet: Turn ON/OFF/TOGGLE given LEDs
  • LedBlink: Blinks the LEDs
  • GetKeyStatus: Read the current value of a key
  • TmosSystemProcess: OPBT system processing function
  • LcdClear: Clears the LCD screen.
  • LcdTextColor: Sets the text display color on the LCD screen.
  • LcdTextXY: Sets the coordinates for displaying text on the LCD screen.
  • LcdPrint: Displays a string on the LCD screen.
  • LcdFill: Fills a specified color within a rectangular area.

Standard library

class MemChecker

Class MemChecker provide memory management functions.

  • max: Print the maximum memory footprint value.
  • now: Print the current memory usage value.
  • getMax: Returns the largest memory footprint
  • getNow: Returns the current memory usage value.
  • resetMax:Reset the maximum memory usage value

class SysObj

  • type: Print variable type
  • remove: To remove a variable/object.
  • int: For type conversion.
  • float: For type conversion.
  • str: For type conversion.
  • print: provides print output。

Standard Data Structure

class List

  • append: add an arg after the end of list.
  • getitem: get an arg by the index.
  • setitem: set an arg by the index.
  • len: get the length of list.

class Dict

  • getitem: get an arg by the key.
  • setitem: set an arg by the key.
  • remove: remove an arg by the key.

class ByteArray

Standard Multi-tasking

Standard multi-tasking library provides asynchronous multi-tasking capabilities(task loop).

class Task:

The Task class provides the task loop function, and a task loop can be created by creating an object of the Task class.

  • call_always: regist a function to be called always.
  • call_when: regist a function to be called when fun_when() return ‘True’.
  • call_period_ms: register a function to be called periodically.
  • run_once: run all registered function once.
  • run_forever: run all registered function forever.
  • run_until_ms: run all registered function until time is up.
  • platformGetTick: need be overried to supply the system tick.

Debugger

Debugger module provides features such as breakpoint debugging.

class Debuger

  • set_trace

Struct

class struct

  • pack
  • unpack
  • unpack_from

Time

class time

  • sleep
  • sleep_s
  • sleep_ms
  • time
  • time_ns
  • gmtime
  • localtime
  • mktime
  • ctime
  • asctime
  • tick_ms

System OS

class os

  • mkdir
  • rmdir
  • chdir
  • listdir
  • getcwd
  • open
  • read
  • write
  • lseek
  • close
  • fstat
  • remove
  • rename

class fileStat

  • st_size

class path

  • join
  • split
  • splitext
  • basename
  • dirname
  • exists
  • isdir
  • isfile
  • isabs
  • abspath

JSON

class JSON

  • print
  • getObjectItem
  • getArrayItem
  • getArraySize
  • getType
  • getNext
  • getPrev
  • getChild
  • getValueString
  • getValueInt
  • getValueDouble
  • getString
  • getValue
  • isInvalid
  • isFalse
  • isTrue
  • isBool
  • isNull
  • isNumber
  • isString
  • isArray
  • isObject
  • isRaw
  • addItemToArray
  • addItemToObject
  • Parse

class Null

class True_

class False_

class Bool

class Number

class String

class Raw

class Array

class Object

class StringReference:

class ObjectReference:

class ArrayReference:

System Functions

  • int
  • bool
  • float
  • str
  • iter
  • range
  • print
  • setitem
  • getitem
  • type
  • isinstance
  • len
  • list
  • dict
  • tuple
  • hex
  • ord
  • chr
  • bytes
  • cformat
  • id
  • open
  • dir
  • exec
  • eval
  • getattr
  • setattr
  • hasattr
  • exit
  • input
  • abs
  • max
  • min
  • help
  • reboot
  • clear
  • gcdump

Math Functions

  • ceil
  • fabs
  • floor
  • fmod
  • remainder
  • trunc
  • exp
  • log
  • log2
  • log10
  • pow
  • sqrt
  • acos
  • asin
  • atan
  • atan2
  • cos
  • sin
  • tan
  • degress
  • radianscosh
  • sinh
  • tanh