Welcome to the EyeBot  Version 7 - RPi1
A Controller For Various Hardware IO
Data Structures | Typedefs | Functions
hdt.c File Reference

the code to run hardware sub-windowthe GUI for the EyeBot More...

#include "hdt.h"

Data Structures

struct  HDT_TYPES
 Structure defining HDT Types. More...
 

Typedefs

typedef struct HDT_TYPES HDT_TYPES
 Structure defining HDT Types.
 

Functions

__ssize_t getline (char **__restrict __lineptr, size_t *__restrict __n, FILE *__restrict __stream)
 
int HDTValidate (char *filename)
 checks all HDT entries in given filename. will not check for specific entry (only check entry headers). More...
 
int HDTListEntry (char *filename, HDT_ENTRY *deventry, int count)
 Copy all entries to deventry. user need to free the allocated memory by using free(deventry->buffer). return value may be less than count. More...
 
int HDTFindEntry (void *hdtfile, char *devname, HDT_ENTRY *deventry)
 finds an entry in the hdt file that matches given name and copies the entry to given structure. the newline character is replaced by null. user need to free the allocated memory by using free(deventry->buffer). More...
 
int HDTFindTable (void *hdtfile, char *tabname, HDT_TABLE *tabentry)
 finds a table in the hdt file that matches given name and copies the table data to given structure. More...
 
HDT_TABLEHDTLoadTable (char *filename, HDT_DEVICE *pdevices)
 load all tables needed by pdevices - if found. the return value is a pointer to the first table. the tables are in a linked list allocated with dynamic memory. use HDTClearTable to free up the resources. More...
 
int HDTClearTable (HDT_TABLE *ptables)
 Free the allocated resources for the tables created by HDTLoadTable. More...
 
HDT_CAMHDTLoadCAM (char *filename, char *devname)
 load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources. More...
 
int HDTClearCAM (HDT_CAM *pdevs)
 Free the allocated resources for the <device> created by HDTLoad<device>. More...
 
HDT_MOTORHDTLoadMOTOR (char *filename, char *devname)
 load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources. More...
 
int HDTClearMOTOR (HDT_MOTOR *pdevs)
 Free the allocated resources for the <device> created by HDTLoad<device>. More...
 
HDT_ENCODERHDTLoadENCODER (char *filename, char *devname)
 load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources. More...
 
int HDTClearENCODER (HDT_ENCODER *pdevs)
 Free the allocated resources for the <device> created by HDTLoad<device>. More...
 
int HDTLinkENC2MOT (HDT_ENCODER *pencoders, HDT_MOTOR *pmotors)
 Link the encoders to the motors. More...
 
HDT_PSDHDTLoadPSD (char *filename, char *devname)
 load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources. More...
 
int HDTClearPSD (HDT_PSD *pdevs)
 Free the allocated resources for the <device> created by HDTLoad<device>. More...
 
HDT_SERVOHDTLoadSERVO (char *filename, char *devname)
 load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources. More...
 
int HDTClearSERVO (HDT_SERVO *pdevs)
 Free the allocated resources for the <device> created by HDTLoad<device>. More...
 
HDT_DRIVEHDTLoadDRIVE (char *filename, char *devname)
 load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources. More...
 
int HDTClearDRIVE (HDT_DRIVE *pdevs)
 Free the allocated resources for the <device> created by HDTLoad<device>. More...
 
int HDTLinkDRV2ENC (HDT_DRIVE *pdrives, HDT_ENCODER *pencoders)
 Link the drives to the encoders. More...
 
HDT_IRTVHDTLoadIRTV (char *filename, char *devname)
 load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources. More...
 
int HDTClearIRTV (HDT_IRTV *pdevs)
 Free the allocated resources for the <device> created by HDTLoad<device>. More...
 
HDT_ADCHDTLoadADC (char *filename, char *devname)
 load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources. More...
 
int HDTClearADC (HDT_ADC *pdevs)
 Free the allocated resources for the <device> created by HDTLoad<device>. More...
 
HDT_COMHDTLoadCOM (char *filename, char *devname)
 load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources. More...
 
int HDTClearCOM (HDT_COM *pdevs)
 Free the allocated resources for the <device> created by HDTLoad<device>. More...
 

Detailed Description

the code to run hardware sub-windowthe GUI for the EyeBot

Defines functions used by the HDT system.

Author
Marcus Pham
Remi KEAT & Marcus Pham

Function Documentation

int HDTClearADC ( HDT_ADC pdevs)

Free the allocated resources for the <device> created by HDTLoad<device>.

Parameters
HDT_ADC*pdevs : <device> list to be cleared
Returns
int retVal : always 0
int HDTClearCAM ( HDT_CAM pdevs)

Free the allocated resources for the <device> created by HDTLoad<device>.

Parameters
HDT_CAM*pdevs : <device> list to be cleared
Returns
int retVal : always 0
int HDTClearCOM ( HDT_COM pdevs)

Free the allocated resources for the <device> created by HDTLoad<device>.

Parameters
HDT_COM*pdevs : <device> list to be cleared
Returns
int retVal : always 0
int HDTClearDRIVE ( HDT_DRIVE pdevs)

Free the allocated resources for the <device> created by HDTLoad<device>.

Parameters
HDT_DRIVE*pdevs : <device> list to be cleared
Returns
int retVal : always 0
int HDTClearENCODER ( HDT_ENCODER pdevs)

Free the allocated resources for the <device> created by HDTLoad<device>.

Parameters
HDT_ENCODER*pdevs : <device> list to be cleared
Returns
int retVal : always 0
int HDTClearIRTV ( HDT_IRTV pdevs)

Free the allocated resources for the <device> created by HDTLoad<device>.

Parameters
HDT_IRTV*pdevs : <device> list to be cleared
Returns
int retVal : always 0
int HDTClearMOTOR ( HDT_MOTOR pdevs)

Free the allocated resources for the <device> created by HDTLoad<device>.

Parameters
HDT_MOTOR*pdevs : <device> list to be cleared
Returns
int retVal : always 0
int HDTClearPSD ( HDT_PSD pdevs)

Free the allocated resources for the <device> created by HDTLoad<device>.

Parameters
HDT_PSD*pdevs : <device> list to be cleared
Returns
int retVal : always 0
int HDTClearSERVO ( HDT_SERVO pdevs)

Free the allocated resources for the <device> created by HDTLoad<device>.

Parameters
HDT_SERVO*pdevs : <device> list to be cleared
Returns
int retVal : always 0
int HDTClearTable ( HDT_TABLE ptables)

Free the allocated resources for the tables created by HDTLoadTable.

Parameters
HDT_TABLE*ptables : tables to be cleared
Returns
int retVal : always 0
int HDTFindEntry ( void *  hdtfile,
char *  devname,
HDT_ENTRY deventry 
)

finds an entry in the hdt file that matches given name and copies the entry to given structure. the newline character is replaced by null. user need to free the allocated memory by using free(deventry->buffer).

Parameters
void*hdtfile : hdt file fopen with "rt" flag
char*devname : name of entry to search for
HDT_ENTRY*deventry : storage structure for the entry
Returns
int retVal :
-1 on failure (no entry found)
[entry length] on success
int HDTFindTable ( void *  hdtfile,
char *  tabname,
HDT_TABLE tabentry 
)

finds a table in the hdt file that matches given name and copies the table data to given structure.

Parameters
void*hdtfile : hdt file (fopen with "rt" flag)
char*tabname : name of table to search for
HDT_TABLE*tabentry : storage structure for the table
Returns
int retVal :
-1 on failure (no table found)
[table size] on success
int HDTLinkDRV2ENC ( HDT_DRIVE pdrives,
HDT_ENCODER pencoders 
)

Link the drives to the encoders.

Parameters
HDT_DRIVE*pdrives : list of drive methods
HDT_ENCODER*pencoders : list of encoders
Returns
int retVal :
0 on success
Negative value on failure (number of unconnected link)
int HDTLinkENC2MOT ( HDT_ENCODER pencoders,
HDT_MOTOR pmotors 
)

Link the encoders to the motors.

Parameters
HDT_ENCODER*pencoders : list of encoders
HDT_MOTOR*pmotors : list of motors
Returns
int retVal :
0 on success
Negative value on failure (number of unconnected link)
int HDTListEntry ( char *  filename,
HDT_ENTRY deventry,
int  count 
)

Copy all entries to deventry. user need to free the allocated memory by using free(deventry->buffer). return value may be less than count.

Parameters
char*filename : name of HDT file to be checked for listing
HDT_ENTRY*deventry : storage structure for the entry
intcount : number of deventry storage supplied
Returns
int retVal :
-1 on failure
(number of entries) on success
HDT_ADC* HDTLoadADC ( char *  filename,
char *  devname 
)

load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources.

Parameters
char*filename : hdt file to open
char*devname : device semantics
Returns
HDT_ADC* handle :
0x0 on failure (no <device> found)
(pointer to first <device>) if found
HDT_CAM* HDTLoadCAM ( char *  filename,
char *  devname 
)

load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources.

Parameters
char*filename : hdt file to open
char*devname : device semantics
Returns
HDT_CAM* handle :
0x0 on failure (no <device> found)
(pointer to first <device>) if found
HDT_COM* HDTLoadCOM ( char *  filename,
char *  devname 
)

load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources.

Parameters
char*filename : hdt file to open
char*devname : device semantics
Returns
HDT_COM* handle :
0x0 on failure (no <device> found)
(pointer to first <device>) if found
HDT_DRIVE* HDTLoadDRIVE ( char *  filename,
char *  devname 
)

load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources.

Parameters
char*filename : hdt file to open
char*devname : device semantics
Returns
HDT_DRIVE* handle :
0x0 on failure (no <device> found)
(pointer to first <device>) if found
HDT_ENCODER* HDTLoadENCODER ( char *  filename,
char *  devname 
)

load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources.

Parameters
char*filename : hdt file to open
char*devname : device semantics
Returns
HDT_ENCODER* handle :
0x0 on failure (no <device> found)
(pointer to first <device>) if found
HDT_IRTV* HDTLoadIRTV ( char *  filename,
char *  devname 
)

load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources.

Parameters
char*filename : hdt file to open
char*devname : device semantics
Returns
HDT_IRTV* handle :
0x0 on failure (no <device> found)
(pointer to first <device>) if found
HDT_MOTOR* HDTLoadMOTOR ( char *  filename,
char *  devname 
)

load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources.

Parameters
char*filename : hdt file to open
char*devname : device semantics
Returns
HDT_MOTOR* handle :
0x0 on failure (no <device> found)
(pointer to first <device>) if found
HDT_PSD* HDTLoadPSD ( char *  filename,
char *  devname 
)

load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources.

Parameters
char*filename : hdt file to open
char*devname : device semantics
Returns
HDT_IRTV* handle :
0x0 on failure (no <device> found)
(pointer to first <device>) if found
HDT_SERVO* HDTLoadSERVO ( char *  filename,
char *  devname 
)

load all <device> entry found in the hdt file if devname is null. else, load only the requested device. the return value is a pointer to the first <device>. the <devices> are in a linked list allocated with dynamic memory. use HDTClear<device> to free up the resources.

Parameters
char*filename : hdt file to open
char*devname : device semantics
Returns
HDT_SERVO* handle :
0x0 on failure (no <device> found)
(pointer to first <device>) if found
HDT_TABLE* HDTLoadTable ( char *  filename,
HDT_DEVICE pdevices 
)

load all tables needed by pdevices - if found. the return value is a pointer to the first table. the tables are in a linked list allocated with dynamic memory. use HDTClearTable to free up the resources.

Parameters
char*filename : hdt file to open
HDT_DEVICE*pdevices : devices with tablename in linked list
Returns
HDT_TABLE* table :
0x0 on failure (no table found)
(pointer to first table) if found
int HDTValidate ( char *  filename)

checks all HDT entries in given filename. will not check for specific entry (only check entry headers).

Parameters
char*filename : name of HDT file to be checked
Returns
int retVal :
-1 if incorrect HDT entry found
(number of entries) if otherwise