usb_open(var type)
Detects a USB I/O module and opens the USB port. The type parameter must be 0. Returns 0 when no USB module could be found.
usb_close()
Releases the USB I/O module and closes its USB port.
usb_out(var mode)
Activates the first (mode = 1), second (mode = 2) or both (mode = 3) relays of a USB relay module. mode = 0 deactivates both relays.
usb_setdata64(long addr,long hi,long lo)
Set a 64 bit value (hi.lo) to the given USB register address .
usb_error() : char*
Returns a char* text containing the error message of the last command, or NULL when there was no error.
Remarks:
- Deditec USB Mini Modules can be used to control external equipment. Modules with 2 relays or 8 or 16 inputs or outputs are available from most electronics stores.
- The ackusb.dll must be loaded and ackusb.h must be included for sending commands to the USB port.
- A stand alone alternative to USB modules are NETPORT modules that can be configured by socket commands and can run simple lite-C scripts.
Edition:
A8 C
Example:
#include <acknex.h>
#include <default.c>
#include <ackusb.h>
// control USB relay with the [1] and [2] keys
function main()
{
usb_open(0);
while(1)
{
if(key_1)
usb_out(1); // relay 1
else if(key_2)
usb_out(2); // relay 2
else
usb_out(0);
wait(1);
}
}
function on_exit_event()
{
usb_close();
}
See also:
port_out, port_in, NETPORT
► latest
version online