There are no availible options for this view.

Parent Directory Parent Directory | Revision Log Revision Log

Revision 9 - (download) (annotate)
Tue Mar 27 23:17:18 2007 UTC (2 years, 8 months ago) by apchen
File size: 4625 byte(s)
include license text, change to unix file format, fix typos
    1 (Serial Ports on) Steroids
    2 
    3 enables users to execute remote c functions in python shell over serial interface
    4 , useful for embedded system testing and industrial automation.  It generates c
    5 code for the target and a python script for the host automatically from a c
    6 header file.
    7 
    8 
    9 LICENSES:
   10 
   11 steroids.py is released under GPL license, and the generated c and py code are
   12 released under LGPL license, which means it is OK to include the generated code
   13 in your close-source projects.
   14 
   15 
   16 FEATURES:
   17 
   18 1.  The target c code and the host python script are generated automatically
   19     from a c header file
   20 2.  Supported argument/return types:
   21     a. basic types - integers (signed or unsigned, 8, 16, 32, 64 bits), float
   22                     and double
   23     b. char strings (null terminated)
   24     c. arrays of basic types (except char*, which is a char string here)
   25 3.  The target c code use no external functions (e.g malloc()), can be used even
   26     in the most deeply embedded software
   27 4.  Small footprint with minimum stack size requirement.  Array arguments are
   28     read directly from the read buffer
   29 5.  crc32 is computed and verified for message data over serial interface
   30 6.  Endianness of the target is handled automatically and is transparent to the
   31     user
   32 7.  python! - The remote c function can be called interactively.  And It's ok
   33     not to specify all arguments (default values will be supplied)
   34 
   35 
   36 USAGE:
   37 
   38 the usage of steroids is best illustrated by a concrete example:
   39 
   40 0.  You can download a Null-modem emulator
   41     (http://sourceforge.net/projects/com0com/) to try this out in windows cygwin
   42     .  Make sure you change the name of virtual serial ports CNCA0 and CNCB0 to
   43     COM2 and COM3 after installation
   44 1.  Create a c-header file including all the target c functions you want to be
   45     accessible from the host.  Currently there are some limitations on what
   46     can be in the header file
   47     a. don't include other header files
   48     b. you must typedef the integer type I1,2,4,8 and U1,2,4,8
   49     c. if a function wants to return multiple data values, it should return a
   50         struct pointer and the struct should be defined and typedef'ed
   51     d. if an array is in the arguments or returned struct pointer, the previous
   52         argument/field of the structure will contain the length of the array
   53     see demo.h for example
   54 2.  $./steroids.py demo.h
   55     It will generate steroids_demo.c and steroids_demo.py.  Modify the user
   56     configuration part.  Compile steroids_demo.c with your target software:
   57     $gcc -Wall steroids_demo.c demo.c -o target.exe
   58     run your target software in another cygwin console:
   59     $./target.exe
   60 3.  $python -i steroids_demo.py
   61 >>> friendly()
   62 arguments:
   63 
   64 
   65 return values:
   66 
   67  = 'hello!'
   68 >>> add_em_up()
   69 arguments:
   70 
   71 len = 0
   72 array = []
   73 
   74 return values:
   75 
   76  = 0.0
   77 >>> add_em_up(array=[x+1 for x in range(10)])
   78 arguments:
   79 
   80 len = 10
   81 array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
   82 
   83 return values:
   84 
   85  = 55.0
   86 >>> loopback(i8=1, u16=0x30, i32=-5, u64=0xffff12345678987, f=3.14159, cstr = '
   87 hello world!', array_len=10, u16_array=[3,4,5])
   88 arguments:
   89 
   90 i8 = 1
   91 u8 = 0x0 = 0
   92 i16 = 0
   93 u16 = 0x30 = 48
   94 i32 = -5
   95 u32 = 0x0 = 0
   96 i64 = 0
   97 u64 = 0xffff12345678987 = 1152905163420699015
   98 cstr = 'hello world!'
   99 array_len = 10
  100 u16_array = [3, 4, 5, 0, 0, 0, 0, 0, 0, 0]
  101 f = 3.14159
  102 d = 0
  103 
  104 return values:
  105 
  106 i8 = 1
  107 u8 = 0x0 = 0
  108 i16 = 0
  109 u16 = 0x30 = 48
  110 i32 = -5
  111 u32 = 0x0 = 0
  112 i64 = 0
  113 u64 = 0xffff12345678987 = 1152905163420699015
  114 cstr = 'hello world!'
  115 array_len = 10
  116 u16_array = (3, 4, 5, 0, 0, 0, 0, 0, 0, 0)
  117 f = 3.14159011841
  118 d = 0.0
  119 >>>
  120 
  121 
  122 Q and A:
  123 
  124 Q.  Why not ([ethernet|parallel|IrDA|internet|USB] on) steroids?
  125 A.  serial ports are more ubiquitous.  They are available for most embedded
  126     systems, including satellite electronics and set-top boxes.  Besides, all
  127     other interfaces can easily emulate serial ports and abuse steroids
  128 
  129 Q.  Why not use RPC or GDB to execute remote c functions?
  130 A.  You can, but they are too complicated to use for ordinary software engineers
  131     like me.
  132 
  133 
  134 KNOWN BUGS:
  135 
  136 -the python script doesn't work on big endian host yet
  137 -the python script doesn't work on Windows without CYGWIN because it uses
  138     termios module, which is only available in unix-like environment
  139 
  140 
  141 COMPATIBILITY:
  142 
  143 -host python script tested on Windows (CYGWIN) and linux with python 2.4.3
  144 -target c code tested on i386 and MIPS based targets with gcc compiler
  145 
  146 
  147 TO DO:
  148 
  149 - add data representation GUI for returned data
  150 - add mechanism to sync and control multiple targets
  151 - add native support for remote JAVA methods execution without using JNI
  152 
  153 
  154 Any questions:
  155 
  156 Send e-mail to RaveLab, Inc.
  157 steroids@ravelab.com