Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.naic.edu/~phil/software/datataking/vxWorks.html
Дата изменения: Tue Mar 5 00:37:25 2013
Дата индексирования: Sat Mar 1 02:02:21 2014
Кодировка:
Поисковые слова: п р п п р п п р п п р п п р п п р п п р п п р п п р п п р п п р п п р п
|
VxWorks datatking programs
29mar06
VxWorks Interpreter
Converting rpc routines on vxWorks to use daemons:
VxWorks
tcl interpreter
A TCL interpreter has been ported to vxWorks.
4 AO commands have been written and then integrated into 2
separate programs. The programs are:
Program
|
Source
(/home/phil/vw/datatk/aotcl)
|
AO
commands included
|
vmeCpus used on
|
aogProg
|
aogProg.c
|
aog_Cmd
|
|
mcpProg
|
mcpProg.c
|
mcp_Cmd, pnt_Cmd, aog_Cmd
aosock_Cmd |
da,cor
|
pntTcl
|
pntTcl.c
|
pnt_Cmd, aog_Cmd
|
pnt
|
The aoCommands that have been added are:
- aog_Cmd: generic stuff: timing, delays. No device
specific stuff.
- mcp_Cmd: this does the general datataking. It controls
backends and if/lo. runs on da and cor
- pnt_Cmd: interfaces to the telescope pointing,
tiedowns,turret.
- aosock_Cmd: lets you do regular socket
i/o from a tcl script.
aosock: socket communications from Tcl in
vxWorks. (top)
Do socket i/o from a vxWorks tcl interpreter. The
cmd has been added to:
- aosockProg: tcl interpreter to test aosock
- mcpProg: tcl interpreter to control datataking.
Notes:
- If TCL_ERROR is returned then then command will be aborted
(or any function it is called from). If you don't want this ,
then use catch
- You need to call aosock socket to get the file descriptor
before make any of the other calls (except aosock {list,?}).
- Errors will usually return with an error message included in
the return value.
Usage:
- aosock (cl)ose $sockFd
- Close socket, free up resources. sockFd no longer availabel
to use.
- aosock (co)nnect $sockFd $ipAdr
$portNum {$tmOutTicks}
- Connect to socket at $ipAdr $portNum.
- Returns:
- TCL_OK if connect
- TCL_ERROR if:
- wrong number of args
- port number is not an integer. If tmOutTick supplied
then it must also be an integer.
- If not connection is made within tmOutTicks. default is
60 = 1 second.
- Example:
- aosock connect $sockFd "192.65.176.2" 7
- aosock (g)ets $sockFd inpLine
{$tmOutTicks}
- get a line of text.
- The termination character in newline.
- Returns:
- TCL_OK with n telling of the bytes returned:
- n >0 bytes return. A line with just a
newline will return 0 bytes.
- n=0 timeout.. so hard to distinguish between
newline only line..
- n = -1 : EOF. socket will automatically be
close on return. You can no longer use $sockFd.
- TCL_ERROR:
- Wrong number of args
- bad $sockFd
- tmOutTicks not an integer
- select error (not including timeout)
- read error (not including eof).
- Example:
- set n [aosock gets $sockFd inpLine 120]
- inpLine will hold the data
- aosock (l)ist
- list all of the sockets currently open
- returns each on a separate line
- N .. number of sockets
currently open
- sockFd sockState bufLen
- sockFd is socket number
- sockState: 0 not initialized, 1 sock socket
completed, 2 connect completed.
- bufLen - length of buffer to use for input.
- aosock (p)uts $sockFd $outBuf
- output a line sockFd. Output stops at the end of string or
the first newline found.
- One newline will be output at the end.
- Returns:
- TCL_OK
- TCL_ERROR
- wrong number of args
- Length of variable longer than bufLen for socket.
- error on write including:eof, byteswritten != bytes
requested.
- the socket will be closed automatically.
- Example:
- aosock puts $sockFd "this is a test"
- aosock (r)ead $sockFd inpBuf
{$tmOutTicks}
- Read all available bytes from socket.
- If bytes are already available in the input buffer then
don't bother to issue a read.
- Data will be stored in inpBuf. No newline will be appended.
- Returns:
- TCL_OK
- n>0 is the number of bytes
- n=0 timeout waiting for data
- n=-1 eof.. socket will be automatically closed
- inpBuf will have n bytes of data.
- TCL_ERROR
- Incorrect number of args,
- tmOutTicks not an integer.
- bad socket.
- select error (excluding timeout). read error (excluding
eof).
- ctrl-c from the terminal.
- Example:
- set n [aosock read $sockFd inpBuf 120]
- aosock (s)ocket
- open a socket
- After open tcpNodelay is enabled.
- Returns:
- TCL_OK
- sockFd set to socket. Format is sockNN where NN is the
file descriptor from the open.
- TCL_ERROR
- too many sockets currently open (current max is 10).
- error on socket call.
- Example:
- set sockFd [aosock socket]
- aosock (w)rite $sockFd $outBuf
- write outBuf to socket.
- Returns:
- TCL_OK
- TCL_ERROR
- Wrong number of args
- length of outBuf larger then socket buffer.
- eof or error on write
- in both cases the socket will be closed automatically.
- aosock ?
- Print list of aosock commands
Converting rpc programs on vxWorks to daemons
The rpc version (1992) used on vxWorks is
pretty old and is not compatible with newer versions. These
routines should be changed to use regular sockets with some
daemons running on vxWorks:
- SuFile .. setup file loading
- Aeronomy uses this to pass the setup info to various program
scripts they run
- /home/phil/vw/rpc/suFile/ - holds rpc code
- ~phil/vw/datatk/mcp/ sufLib.c used by sun
routines that call sufFile rpc's.
- on Sun:
- it passes a string id and a setupfile to read
- On Vxworks
- get ths idKey and filename
- reads the setupfile.This is an ascii file
- special lines in setup file start with #!
- hdr hdrlen filename
- This is a binary header file to get
- spsProg rawDat file.sps.cur
- This info is then sent to mcpProg via mcpSUFLoad(). This
is compiled into the mcp_Cmd.c program.
- Problem will be reading the binary data. Sun ->
vxWorks was all big endian. rd program on linux needs to
store binary in big endian,
c
home_~phil