-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This wiki describes API served by XpressNET dynamic-linked library. This API is used e.g. by hJOPserver.
This file describes XpressNET library API, however, the API is not for XpressNET library only. It is (hopefully) designed general enough to be used with any system supporting locomotive control (e.g. LocoNET).
Every char16_t*
is a pointer to null-terminated UTF-16 string. All strings are
in UTF-16.
ok
and err
contain references to callback functions. This library
guarantees exactly 1 of the callbacks to be always called. Functions taking
err
as an argument never return value. When error happens in a time of
calling, err
event in called.
All functions never raise any exceptions.
API version is unsigned int
with LSB meaning the major version and second LSB
meaning minor version. The rest of bytes is 0.
Library may support multiple version of API and caller may support multiple
version of API too. It is caller's responsibility to choose which version of
API to use. Caller determines which versions of API library supports by
calling apiSupportsVersion
functions. When it chooses API version, it should
call apiSetVersion
so the library knows the intended version of API too.
These functions should be the first functions caller calls in the library.
- Asks library if it supports API version
version
.
- Sets the API version.
- Should be called at least once at the beginning.
- Returns 0 on success.
- Returns
TRK_UNSUPPORTED_API_VERSION
when tried to set unsupported API version.
- Returns bitmask of features that library supports.
- Current list of features: empty.
- Loads library configuration from file
filename
. - This function could only be called when device is closed.
- Returns 0 by default.
- Returns
TRK_FILE_CANNOT_ACCESS
when cannot access configuration file. - Returns
TRK_FILE_DEVICE_OPENED
when trying to load configuration with connected command station. - Old configuration is kept if cannot access file.
- Filename
filename
is used for future saving of config. - Caller is recommended to call this function right after API version determination.
- On start, library can load default config from from its working path, however in most cases there would be no config file. The responsibility for loading config file at startup is mainly on caller.
- Saves current library configuration to file
filename
- Returns 0 by default.
- Returns
TRK_FILE_CANNOT_ACCESS
when cannot save configuration file. - This function could be called at any time.
- Connects to XpressNET.
- Interface name is the responsibility of library (it stores it & allows user to change it).
- Calls
beforeOpen
andafterOpen
events. - Returns 0 by default.
- Returns
TRK_ALREADY_OPENNED
when device is already opened. - Returns
TRK_CANNOT_OPEN_PORT
whet device open was unsuccessful.
- Disconnects from XpressNET.
- Calls
beforeClose
andafterClose
events. -
afterClose
event is guranteed to be called (we always manage to close the device somehow). - Returns 0 by default.
- Returns
TRK_NOT_OPENED
when device not opened.
- Returns if library is connected to the command station (COM port opened),
-
OnOpenError
event is called when there was a problem opening the device. - After the
OnOpenError
is called,AfterClose
is always called.
- Initial version
- Add
bindOnOpenError
function &OnOpenError
event.