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:

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