Menu

Linux C Library

Majenko Technologies

Linux C Library

You can use the C library on Linux to communicate with the Arduino through the ICSC protocol. It is even possible for the Arduino to communicate with the PC and with other devices on the local Serial connection at the same time. This allows you to share the USB and the Serial connection.

Headers

To access the functions, include the icsc.h file in the start of your program:

#include <icsc.h>

Linking

Link your program with the icsc library:

cc -o myproc myprog.c -licsc

Library functions

icsc_begin

int icsc_begin(unsigned char station, unsigned int baud, char *device);

Initialize the ICSC connection. "station" is the station number of the local computer. "baud" is the baud rate in the form Bxxxxx, such as B115200, and device is the name of the device to use.

Example:

icsc_begin(4, B115200, "/dev/ttyACM0");

icsc_send

void icsc_send(unsigned char station, unsigned char command, unsigned char len, char *data);

Send a packet of data to a remote station. "station" is the ID of the station to send to, "command" is the command code to send, "len" is the length of the data, and "data" is a pointer to the data to send.

Example:

icsc_send(1, 'R', 3, (char *)&myArray);

icsc_process

void icsc_process();

Process incoming data. This function should be called as often as possible to deal with incoming serial data.

Example:

icsc_process();

icsc_register_command

void icsc_register_command(char command, callbackFunction function);

Register a function to be executed when a specific command is received.

Example:

void tick(unsigned char source, char command, unsigned char length, char *data)
{
  // ...
}

icsc_register_command('T', &tick);

icsc_unregister_command

icsc_unregister_command(commandID);

Remove a registered callback command from the list of recognized commands at this station.

Example:

icsc_unregister_command('T');

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.