Functions | |
int | Usb_SetActive (int state) |
Sets whether the Usb subsystem is active. | |
int | Usb_GetActive () |
Read the active state of the Usb system. | |
int | Usb_Read (char *buffer, int length) |
Read from the USB port. | |
int | Usb_Write (char *buffer, int length) |
Write to the USB port. | |
int | Usb_SlipSend (char *buffer, int length) |
Write to the USB port using SLIP codes to packetize messages. | |
int | Usb_SlipReceive (char *buffer, int length) |
Read from the USB port using SLIP codes to de-packetize messages. |
On OS X, the system USB CDC driver is used - no external drivers are needed. An entry in /dev is created - similar to /dev/cu.usbmodem.xxxx. It may be opened for reading and writing like a regular file using the standard POSIX open(), close(), read(), write() functions.
On Windows, the first time the device is seen, it needs to be pointed to a .INF file containing additional information - the make_controller_kit.inf in the same directory as this file. Once Windows sets this up, the device can be opened as a normal COM port. See also the mchelper codebase for code snippets.
int Usb_GetActive | ( | void | ) |
int Usb_Read | ( | char * | buffer, | |
int | length | |||
) |
Read from the USB port.
Pass in a pointer to a char buffer to read into, and the number of characters requested to read. This function will return immediately with the number of characters read.
buffer | A pointer to a char buffer to read into | |
length | An integer specifying the number of characters to read |
int Usb_SetActive | ( | int | state | ) |
int Usb_SlipReceive | ( | char * | buffer, | |
int | length | |||
) |
Read from the USB port using SLIP codes to de-packetize messages.
SLIP (Serial Line Internet Protocol) is a way to separate one "packet" from another on an open serial connection. This is the way OSC messages are sent over USB, for example. SLIP uses a simple start/end byte and an escape byte in case your data actually contains the start/end byte. This function will block until it has received a complete SLIP encoded message, and will pass back the original message with the SLIP codes removed.
Check the Wikipedia description of SLIP at http://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol
buffer | A pointer to a char buffer to read into | |
length | An integer specifying the number of characters to read |
int Usb_SlipSend | ( | char * | buffer, | |
int | length | |||
) |
Write to the USB port using SLIP codes to packetize messages.
SLIP (Serial Line Internet Protocol) is a way to separate one "packet" from another on an open serial connection. This is the way OSC messages are sent over USB, for example. SLIP uses a simple start/end byte and an escape byte in case your data actually contains the start/end byte. Pass your normal buffer to this function to have the SLIP codes inserted and then write it out over USB.
Check the Wikipedia description of SLIP at http://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol
buffer | A pointer to a char buffer to write from | |
length | An integer specifying the number of characters to write |
int Usb_Write | ( | char * | buffer, | |
int | length | |||
) |
Write to the USB port.
Pass in a pointer to a char buffer to from, and the number of characters requested to write.
buffer | A pointer to a char buffer to write from | |
length | An integer specifying the number of characters to write |