iogw
IoGW is the gateway between applications and MAE I/O resources.
This daemon manages I/O resources across all CommHub spokes and root hub, such as files, serial ports, USB raw ports, ptty's, pipes to programs, sockets, UDP connections and TCP connections. For specially named resources, it implements a virtual file system.
Apps can use the IOPort class to access iogw resources and virtual file system files.
A resource must have a unique name and be present in the IORegistry database table. Use the tioreg command to add/change/view resources and virtual file system structure.
IoGW reads these commhub attributes (that originate from the commhub.ini file):
Keyword |
Value |
poll |
Default number of seconds to wait when polling dynamic/changing files. Default: 30 |
Use the IPPort class to open, read, write, close, etc from MAE I/O resources. Behind the scenes, the IPPort class uses the IoAPI class to interface with IoGW.
iogw uses these database tables:
Table Name |
Description |
Table of I/O resources that iogw makes available to MAE applications. See tioreg for registry setup and maintenance. | |
Table of virtual file system nodes basic information. |
The following messages may be received on the io channel.
MsgTag |
Description |
open |
Open the named resource in the mode specified. A named resource maps to a URL (see tioreg, which iogw uses to locate and open the resource. iogw then sends data and status messages back for the resource. name - the name of the registered I/O resource mode - like open(1), modes allowed are: r, rw, w, r+, w+, a; b is ignored - it is assumed cbtag - base callback keyword to handle various messages sent to app using the resource. Use the IoPort class to manage. Variously, "open", "eof", "tell" will be added to this cbtag. cbdata - callback data sent to the app with every message sent to app using the resoruce @return true if sent |
putchar |
Send a character (identified as c) to the device. ioId - the instance of the I/O resource c - the character to output ioChannel - name of channel to reach the spoke @return true if sent to iogw |
writetext |
Send some text (identified as text) to the device. text is simply a series of characters. No implied newline. ioId - the instance of the I/O resource text - the text string to output ioChannel - name of channel to reach the spoke @return true if sent to iogw |
writebin |
Send a block of data to the device. ioId - the instance of the I/O resource data - the block of data to output ioChannel - name of channel to reach the spoke @return true if sent to iogw |
seek |
Move to a specific file position in the resource. This does not apply to streaming data sources. ioId - the instance of the I/O resource offset - the file position to seek ioChannel - name of channel to reach the spoke @return true if sent to iogw |
lock |
Attempt to lock access to this resource/file. If an exclusive lock has already been obtained, then it can be switched to shared. exclusive - Flag: true if nothing else allowed to read or write to this resource, false if other apps can read this resource wait - Flag: true if app should wait until the lock has been released - this will block the app @return true if the lock was acquired, false if it was not acquired |
unlock |
Attempt to lock access to this resource/file. If an exclusive lock has already been obtained, then it can be switched to shared. exclusive - Flag: true if nothing else allowed to read or write to this resource, false if other apps can read this resource wait - Flag: true if app should wait until the lock has been released - this will block the app @return true if the lock was acquired, false if it was not acquired |
close |
Tell iogw that the app no longer needs access to this resource. ioId - the instance of the I/O resource ioChannel - name of channel to reach the spoke @return true if sent |
fsverify |
Internal iogw only; not for app use. Reach out to iogw on a spoke to verify a file still exists. The spoke is expected to reply with fsconfirm() or fsupdate(). node - the file/dir node to check for existance ioChannel - name of channel to reach the spoke @return true if sent |
fsreview |
Internal iogw only; not for app use. Reach out to iogw on a spoke to verify directory contents of the resource id provided. Reply with fsupdate() for each directory entry. dirResourceId - the IORegistry record id for the directory/file path ioChannel - name of channel to reach the spoke @return true if sent |
fsconfirm |
Internal iogw only; not for app use. A spoke is informing the hub iogw about a file that still exists. node - the file/dir node to check for existance size - for regular files, the file size @return true if sent |
fsupdate |
Internal iogw only; not for app use. A spoke is informing the hub iogw about a file that still exists. node - the file/dir node to check for existance change - one of: deleted, newdir, newfile size - for regular files, the file size @return true if sent |
vfs.ls |
Given a MAE directory path, return a list of all files under it. A filename with a trailing / is a directory. maepath - the MAE directory path @return Resulting data from the call. Use RemoteService::getError(result) to get any error; if no error, then call worked. Filenames appear in node[0], node[1], node[2], etc. with properties id, name, type (e.g. dir or file) |
vfs.stat |
Given a MAE directory path, return details about it. A filename must begin with /. If there's no leading /, then maepathandfilename is taken as an IORegistry name. maepathandfilename - the MAE full filename or directory to check statbuf - (output) a structure to contain the various details about the pathname @return errno for the operation: 0 upon success ENOENT if file does not exist |
The following messages may be received on the tvfs channel.