Refactoring to use function pointers for devices updates

This commit is contained in:
Paul Dino Jones 2023-04-07 07:19:43 +00:00
parent 49144f9429
commit 5eb136312b
16 changed files with 396 additions and 194 deletions

View File

@ -1,6 +1,7 @@
#ifndef _ARDUINO_H
#define _ARDUINO_H
#include "../simdevice.h"
#include "../serialdevice.h"
int arduino_update(SerialDevice* serialdevice, SimData* simdata);

View File

@ -3,21 +3,28 @@
#include <string.h>
#include <unistd.h>
#include "simdevice.h"
#include "serialdevice.h"
#include "serial/arduino.h"
#include "../helper/parameters.h"
#include "../simulatorapi/simdata.h"
#include "../slog/slog.h"
int serialdev_update(SerialDevice* serialdevice, SimData* simdata)
int serialdev_update(SimDevice* this, SimData* simdata)
{
SerialDevice* serialdevice = (void *) this->derived;
arduino_update(serialdevice, simdata);
return 0;
}
int serialdev_free(SerialDevice* serialdevice)
int serialdev_free(SimDevice* this)
{
SerialDevice* serialdevice = (void *) this->derived;
arduino_free(serialdevice);
free(serialdevice);
return 0;
}
@ -33,3 +40,25 @@ int serialdev_init(SerialDevice* serialdevice)
return error;
}
static const vtable serial_simdevice_vtable = { &serialdev_update, &serialdev_free };
SerialDevice* new_serial_device(DeviceSettings* ds) {
SerialDevice* this = (SerialDevice*) malloc(sizeof(SerialDevice));
this->m.update = &update;
this->m.free = &simdevfree;
this->m.derived = this;
this->m.vtable = &serial_simdevice_vtable;
int error = serialdev_init(this);
if (error != 0)
{
free(this);
return NULL;
}
return this;
}

View File

@ -2,26 +2,6 @@
#define _SERIALDEVICE_H
#include <libserialport.h>
#include "../helper/parameters.h"
#include "../simulatorapi/simdata.h"
typedef enum
{
SERIALDEV_UNKNOWN = 0,
SERIALDEV_ARDUINO = 1
}
SerialType;
typedef struct
{
int id;
SerialType type;
struct sp_port* port;
}
SerialDevice;
int serialdev_update(SerialDevice* serialdevice, SimData* simdata);
int serialdev_init(SerialDevice* serialdevice);
int serialdev_free(SerialDevice* serialdevice);
#endif

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include "simdevice.h"
#include "../helper/parameters.h"
@ -6,80 +7,99 @@
#include "../simulatorapi/simdata.h"
#include "../slog/slog.h"
int devupdate(SimDevice* simdevice, SimData* simdata)
int update(SimDevice* this, SimData* simdata)
{
if (simdevice->initialized==false)
{
return 0;
((vtable*)this->vtable)->update(this, simdata);
}
switch ( simdevice->type )
int simdevfree(SimDevice* this)
{
case SIMDEV_USB :
usbdev_update(&simdevice->d.usbdevice, simdata);
break;
case SIMDEV_SOUND :
sounddev_update(&simdevice->d.sounddevice, simdata);
break;
case SIMDEV_SERIAL :
serialdev_update(&simdevice->d.serialdevice, simdata);
break;
((vtable*)this->vtable)->free(this);
}
int devupdate(SimDevice* this, SimData* simdata)
{
return 0;
}
int devfree(SimDevice* simdevice)
int devfree(SimDevice* simdevices, int numdevices)
{
if (simdevice->initialized==false)
slogi("freeing %i simdevices...", numdevices);
int devices = 0;
for (int j = 0; j < numdevices; j++)
{
slogw("Attempt to free an uninitialized device");
return MONOCOQUE_ERROR_INVALID_DEV;
}
switch ( simdevice->type )
SimDevice simdev = simdevices[j];
if (simdev.initialized == true)
{
case SIMDEV_USB :
usbdev_free(&simdevice->d.usbdevice);
break;
case SIMDEV_SOUND :
sounddev_free(&simdevice->d.sounddevice);
break;
case SIMDEV_SERIAL :
serialdev_free(&simdevice->d.serialdevice);
break;
simdev.free(&simdev);
}
}
free(simdevices);
return 0;
}
int devinit(SimDevice* simdevice, DeviceSettings* ds)
int devinit(SimDevice* simdevices, int numdevices, DeviceSettings* ds)
{
slogi("initializing simdevice...");
simdevice->initialized = false;
int err = 0;
slogi("initializing simdevices...");
int devices = 0;
switch ( ds->dev_type )
for (int j = 0; j < numdevices; j++)
{
case SIMDEV_USB :
simdevice->type = SIMDEV_USB;
simdevice->d.usbdevice.type = USBDEV_UNKNOWN;
err = usbdev_init(&simdevice->d.usbdevice, ds);
break;
case SIMDEV_SOUND :
simdevice->type = SIMDEV_SOUND;
err = sounddev_init(&simdevice->d.sounddevice);
break;
case SIMDEV_SERIAL :
simdevice->type = SIMDEV_SERIAL;
err = serialdev_init(&simdevice->d.serialdevice);
break;
default :
sloge("Unknown device type");
err = MONOCOQUE_ERROR_UNKNOWN_DEV;
break;
simdevices[j].initialized = false;
if (ds[j].dev_type == SIMDEV_USB) {
USBDevice* sim = new_usb_device(&ds[j]);
if (sim != NULL)
{
simdevices[j].initialized = true;
simdevices[j] = sim->m;
devices++;
}
else
{
slogw("Could not initialize USB Device");
}
}
if (err==0)
if (ds[j].dev_type == SIMDEV_SOUND) {
SoundDevice* sim = new_sound_device(&ds[j]);
if (sim != NULL)
{
simdevice->initialized = true;
simdevices[j].initialized = true;
simdevices[j] = sim->m;
devices++;
}
return err;
else
{
slogw("Could not initialize Sound Device");
}
}
if (ds[j].dev_type == SIMDEV_SERIAL) {
SerialDevice* sim = new_serial_device(&ds[j]);
if (sim != NULL)
{
simdevices[j].initialized = true;
simdevices[j] = sim->m;
devices++;
}
else
{
slogw("Could not initialize Serial Device");
}
}
}
return devices;
}

View File

@ -9,26 +9,100 @@
#include "../helper/confighelper.h"
#include "../simulatorapi/simdata.h"
typedef struct SimDevice SimDevice;
typedef struct
struct SimDevice
{
const void* vtable;
int (*update)(SimDevice*, SimData*);
int (*free)(SimDevice*);
void* derived;
int id;
bool initialized;
DeviceType type;
};
typedef struct {
int (*update)(SimDevice*, SimData*);
int (*free)(SimDevice*);
} vtable;
/********* Serial Devices *****/
typedef enum
{
SERIALDEV_UNKNOWN = 0,
SERIALDEV_ARDUINO = 1
}
SerialType;
typedef struct
{
SimDevice m;
int id;
SerialType type;
struct sp_port* port;
}
SerialDevice;
int serialdev_update(SimDevice* this, SimData* simdata);
int serialdev_free(SimDevice* this);
SerialDevice* new_serial_device(DeviceSettings* ds);
/********* USB HID Devices *****/
typedef enum
{
USBDEV_UNKNOWN = 0,
USBDEV_TACHOMETER = 1
}
USBType;
typedef struct
{
SimDevice m;
int id;
USBType type;
union
{
USBDevice usbdevice;
SoundDevice sounddevice;
SerialDevice serialdevice;
} d;
TachDevice tachdevice;
} u;
}
SimDevice;
USBDevice;
int usbdev_update(SimDevice* this, SimData* simdata);
int usbdev_free(SimDevice* this);
USBDevice* new_usb_device(DeviceSettings* ds);
/********* Sound Devices *****/
typedef struct
{
SimDevice m;
int id;
SoundType type;
PATestData sounddata;
PaStreamParameters outputParameters;
PaStream* stream;
}
SoundDevice;
int sounddev_update(SimDevice* this, SimData* simdata);
int sounddev_free(SimDevice* this);
SoundDevice* new_sound_device(DeviceSettings* ds);
/***** Generic Methods *********/
int update(SimDevice* simdevice, SimData* simdata);
int devupdate(SimDevice* simdevice, SimData* simdata);
int devinit(SimDevice* simdevice, DeviceSettings* ds);
int devinit(SimDevice* simdevices, int numdevices, DeviceSettings* ds);
int devfree(SimDevice* simdevice);
int devfree(SimDevice* simdevices, int numdevices);
int simdevfree(SimDevice* this);
#endif

View File

@ -1,7 +1,8 @@
#ifndef _USB_GENERIC_SHAKER_H
#define _USB_GENERIC_SHAKER_H
#include "../sounddevice.h"
//#include "../sounddevice.h"
#include "../simdevice.h"
int usb_generic_shaker_init(SoundDevice* sounddevice);
int usb_generic_shaker_free(SoundDevice* sounddevice);

View File

@ -1,13 +1,17 @@
#include <stdio.h>
#include <stdlib.h>
#include "simdevice.h"
#include "sounddevice.h"
#include "sound/usb_generic_shaker.h"
#include "../simulatorapi/simdata.h"
#include "../helper/parameters.h"
#include "../slog/slog.h"
int sounddev_update(SoundDevice* sounddevice, SimData* simdata)
int sounddev_update(SimDevice* this, SimData* simdata)
{
SoundDevice* sounddevice = (void *) this->derived;
sounddevice->sounddata.table_size = 44100/(simdata->rpms/60);
sounddevice->sounddata.gear_sound_data = 0;
@ -18,9 +22,15 @@ int sounddev_update(SoundDevice* sounddevice, SimData* simdata)
sounddevice->sounddata.last_gear = simdata->gear;
}
int sounddev_free(SoundDevice* sounddevice)
int sounddev_free(SimDevice* this)
{
return usb_generic_shaker_free(sounddevice);
SoundDevice* sounddevice = (void *) this->derived;
usb_generic_shaker_free(sounddevice);
free(sounddevice);
return 0;
}
int sounddev_init(SoundDevice* sounddevice)
@ -36,3 +46,19 @@ int sounddev_init(SoundDevice* sounddevice)
usb_generic_shaker_init(sounddevice);
}
static const vtable sound_simdevice_vtable = { &sounddev_update, &sounddev_free };
SoundDevice* new_sound_device(DeviceSettings* ds) {
SoundDevice* this = (SoundDevice*) malloc(sizeof(SoundDevice));
this->m.update = &update;
this->m.free = &simdevfree;
this->m.derived = this;
this->m.vtable = &sound_simdevice_vtable;
sounddev_init(this);
return this;
}

View File

@ -3,9 +3,6 @@
#include "portaudio.h"
#include "../simulatorapi/simdata.h"
#include "../helper/parameters.h"
typedef enum
{
SOUNDDEV_UNKNOWN = 0,
@ -28,18 +25,4 @@ typedef struct
}
PATestData;
typedef struct
{
int id;
SoundType type;
PATestData sounddata;
PaStreamParameters outputParameters;
PaStream* stream;
}
SoundDevice;
int sounddev_update(SoundDevice* sounddevice, SimData* simdata);
int sounddev_init(SoundDevice* sounddevice);
int sounddev_free(SoundDevice* sounddevice);
#endif

View File

@ -1,14 +1,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include "usbdevice.h"
#include "simdevice.h"
#include "../helper/parameters.h"
#include "../simulatorapi/simdata.h"
#include "../slog/slog.h"
int usbdev_update(USBDevice* usbdevice, SimData* simdata)
int usbdev_update(SimDevice* this, SimData* simdata)
{
USBDevice* usbdevice = (void *) this->derived;
switch ( usbdevice->type )
{
case USBDEV_UNKNOWN :
@ -20,8 +24,10 @@ int usbdev_update(USBDevice* usbdevice, SimData* simdata)
return 0;
}
int usbdev_free(USBDevice* usbdevice)
int usbdev_free(SimDevice* this)
{
USBDevice* usbdevice = (void *) this->derived;
switch ( usbdevice->type )
{
case USBDEV_UNKNOWN :
@ -30,6 +36,8 @@ int usbdev_free(USBDevice* usbdevice)
break;
}
free(usbdevice);
return 0;
}
@ -47,3 +55,24 @@ int usbdev_init(USBDevice* usbdevice, DeviceSettings* ds)
return error;
}
static const vtable usb_simdevice_vtable = { &usbdev_update, &usbdev_free };
USBDevice* new_usb_device(DeviceSettings* ds) {
USBDevice* this = (USBDevice*) malloc(sizeof(USBDevice));
this->m.update = &update;
this->m.free = &simdevfree;
this->m.derived = this;
this->m.vtable = &usb_simdevice_vtable;
int error = usbdev_init(this, ds);
if (error != 0)
{
free(this);
return NULL;
}
return this;
}

View File

@ -2,29 +2,5 @@
#define _USBDEVICE_H
#include "tachdevice.h"
#include "../helper/confighelper.h"
#include "../simulatorapi/simdata.h"
typedef enum
{
USBDEV_UNKNOWN = 0,
USBDEV_TACHOMETER = 1
}
USBType;
typedef struct
{
int id;
USBType type;
union
{
TachDevice tachdevice;
} u;
}
USBDevice;
int usbdev_update(USBDevice* usbdevice, SimData* simdata);
int usbdev_init(USBDevice* usbdevice, DeviceSettings* ds);
int usbdev_free(USBDevice* usbdevice);
#endif

View File

@ -165,7 +165,7 @@ int showstats(SimData* simdata)
fflush(stdout);
}
int looper(SimDevice* devices[], int numdevices, Simulator simulator)
int looper(SimDevice* devices, int numdevices, Simulator simulator)
{
slogi("preparing game loop with %i devices...", numdevices);
@ -203,16 +203,16 @@ int looper(SimDevice* devices[], int numdevices, Simulator simulator)
}
for (int x = 0; x < numdevices; x++)
{
if (devices[x]->type == SIMDEV_SERIAL)
if (devices[x].type == SIMDEV_SERIAL)
{
if(t>=update_rate)
{
devupdate(devices[x], simdata);
devices[x].update(&devices[x], simdata);
}
}
else
{
devupdate(devices[x], simdata);
devices[x].update(&devices[x], simdata);
}
}
@ -238,3 +238,67 @@ int looper(SimDevice* devices[], int numdevices, Simulator simulator)
return 0;
}
int tester(SimDevice* devices, int numdevices)
{
slogi("preparing game loop with %i devices...", numdevices);
SimData* simdata = malloc(sizeof(SimData));
struct termios newsettings, canonicalmode;
tcgetattr(0, &canonicalmode);
newsettings = canonicalmode;
newsettings.c_lflag &= (~ICANON & ~ECHO);
newsettings.c_cc[VMIN] = 1;
newsettings.c_cc[VTIME] = 0;
tcsetattr(0, TCSANOW, &newsettings);
fprintf(stdout, "\n");
simdata->maxrpm = 8000;
fprintf(stdout, "Setting rpms to 1000\n");
simdata->rpms = 1000;
for (int x = 0; x < numdevices; x++)
{
devices[x].update(&devices[x], simdata);
}
sleep(3);
fprintf(stdout, "Setting rpms to 2000\n");
simdata->rpms = 2000;
for (int x = 0; x < numdevices; x++)
{
devices[x].update(&devices[x], simdata);
}
sleep(3);
fprintf(stdout, "Setting rpms to 4000\n");
simdata->rpms = 4000;
for (int x = 0; x < numdevices; x++)
{
devices[x].update(&devices[x], simdata);
}
sleep(3);
fprintf(stdout, "Setting rpms to 8000\n");
simdata->rpms = 8000;
for (int x = 0; x < numdevices; x++)
{
devices[x].update(&devices[x], simdata);
}
sleep(3);
simdata->rpms = 100;
for (int x = 0; x < numdevices; x++)
{
devices[x].update(&devices[x], simdata);
}
sleep(1);
fflush(stdout);
tcsetattr(0, TCSANOW, &canonicalmode);
free(simdata);
return 0;
}

View File

@ -1,4 +1,5 @@
#include "../devices/simdevice.h"
#include "../helper/parameters.h"
int looper (SimDevice* devices[], int numdevices, Simulator simulator);
int tester(SimDevice* devices, int numdevices);
int looper (SimDevice* devices, int numdevices, Simulator simulator);

View File

@ -183,7 +183,7 @@ int config_tachometer(int max_revs, int granularity, const char* save_file, SimD
WriteXmlFromArrays(nodes, rpm_array, values_array, max_revs, save_file);
sleep(2);
simdata->pulses = 0;
devupdate(simdevice, simdata);
simdevice->update(simdevice, simdata);
fflush(stdout);
return 0;

View File

@ -23,6 +23,7 @@ ConfigError getParameters(int argc, char** argv, Parameters* p)
struct arg_lit* arg_verbosity1 = arg_litn("v","verbose", 0, 2, "increase logging verbosity");
struct arg_lit* arg_verbosity2 = arg_litn("v","verbose", 0, 2, "increase logging verbosity");
struct arg_lit* arg_verbosity3 = arg_litn("v","verbose", 0, 2, "increase logging verbosity");
struct arg_rex* cmd1 = arg_rex1(NULL, NULL, "play", NULL, REG_ICASE, NULL);
struct arg_str* arg_sim = arg_strn("s", "sim", "<gamename>", 0, 1, NULL);
@ -43,6 +44,13 @@ ConfigError getParameters(int argc, char** argv, Parameters* p)
void* argtable2[] = {cmd2a,cmd2b,arg_max_revs,arg_granularity,arg_save,arg_verbosity2,help2,vers2,end2};
int nerrors2;
struct arg_rex* cmd3 = arg_rex1(NULL, NULL, "test", NULL, REG_ICASE, NULL);
struct arg_lit* help3 = arg_litn(NULL,"help", 0, 1, "print this help and exit");
struct arg_lit* vers3 = arg_litn(NULL,"version", 0, 1, "print version information and exit");
struct arg_end* end3 = arg_end(20);
void* argtable3[] = {cmd3,arg_verbosity3,help3,vers3,end3};
int nerrors3;
struct arg_lit* help0 = arg_lit0(NULL,"help", "print this help and exit");
struct arg_lit* version0 = arg_lit0(NULL,"version", "print version information and exit");
struct arg_end* end0 = arg_end(20);
@ -70,6 +78,7 @@ ConfigError getParameters(int argc, char** argv, Parameters* p)
nerrors0 = arg_parse(argc,argv,argtable0);
nerrors1 = arg_parse(argc,argv,argtable1);
nerrors2 = arg_parse(argc,argv,argtable2);
nerrors3 = arg_parse(argc,argv,argtable3);
if (nerrors1==0)
{
@ -92,6 +101,11 @@ ConfigError getParameters(int argc, char** argv, Parameters* p)
p->verbosity_count = arg_verbosity2->count;
exitcode = E_SUCCESS_AND_DO;
}
else if (nerrors3==0)
{
p->program_action = A_TEST;
exitcode = E_SUCCESS_AND_DO;
}
else
{
if (cmd1->count > 0)
@ -111,12 +125,13 @@ ConfigError getParameters(int argc, char** argv, Parameters* p)
{
if (help->count==0 && vers->count==0)
{
printf("%s: missing <play|config> command.\n",progname);
printf("%s: missing <play|config|test> command.\n",progname);
printf("Usage 1: %s ", progname);
arg_print_syntax(stdout,argtable1,"\n");
printf("Usage 2: %s ", progname);
arg_print_syntax(stdout,argtable2,"\n");
printf("Usage 3: %s ", progname);
arg_print_syntax(stdout,argtable3,"\n");
}
}
exitcode = E_SUCCESS_AND_EXIT;
@ -131,6 +146,8 @@ ConfigError getParameters(int argc, char** argv, Parameters* p)
arg_print_syntax(stdout,argtable1,"\n");
printf("Usage 2: %s ", progname);
arg_print_syntax(stdout,argtable2,"\n");
printf("Usage 3: %s ", progname);
arg_print_syntax(stdout,argtable3,"\n");
printf("\nReport bugs on the github github.com/spacefreak18/monocoque.\n");
exitcode = E_SUCCESS_AND_EXIT;
goto cleanup;
@ -148,6 +165,7 @@ cleanup:
arg_freetable(argtable0,sizeof(argtable0)/sizeof(argtable0[0]));
arg_freetable(argtable1,sizeof(argtable1)/sizeof(argtable1[0]));
arg_freetable(argtable2,sizeof(argtable2)/sizeof(argtable2[0]));
arg_freetable(argtable3,sizeof(argtable3)/sizeof(argtable3[0]));
return exitcode;
}

View File

@ -15,8 +15,9 @@ Parameters;
typedef enum
{
A_PLAY = 0,
A_CONFIG_TACH = 1,
A_CONFIG_SHAKER = 2
A_TEST = 1,
A_CONFIG_TACH = 2,
A_CONFIG_SHAKER = 3
}
ProgramAction;

View File

@ -113,9 +113,8 @@ int main(int argc, char** argv)
SimDevice* tachdev = malloc(sizeof(SimDevice));
SimData* sdata = malloc(sizeof(SimData));
DeviceSettings* ds = malloc(sizeof(DeviceSettings));
error = devsetup("USB", "Tachometer", "None", ms, ds, NULL);
error = devinit(tachdev, ds);
slogi("configuring tachometer with max revs: %i, granularity: %i, saving to %s", p->max_revs, p->granularity, p->save_file);
if (error != MONOCOQUE_ERROR_NONE)
{
@ -123,33 +122,37 @@ int main(int argc, char** argv)
}
else
{
error = devinit(tachdev, 1, ds);
}
if (error != MONOCOQUE_ERROR_NONE)
{
sloge("Could not proceed with tachometer configuration due to error: %i", error);
}
else
{
slogi("configuring tachometer with max revs: %i, granularity: %i, saving to %s", p->max_revs, p->granularity, p->save_file);
config_tachometer(p->max_revs, p->granularity, p->save_file, tachdev, sdata);
}
devfree(tachdev);
free(tachdev);
devfree(tachdev, 1);
//free(tachdev);
free(sdata);
free(ds);
}
else
{
slogi("running monocoque in gameloop mode..");
int error = 0;
error = strtogame(p->sim_string, ms);
if (error != MONOCOQUE_ERROR_NONE)
{
goto cleanup_final;
}
int error = 0;
int configureddevices = config_setting_length(config_devices);
int numdevices = 0;
DeviceSettings* ds[configureddevices];
DeviceSettings ds[configureddevices];
slogi("found %i devices in configuration", configureddevices);
int i = 0;
while (i<configureddevices)
{
error = MONOCOQUE_ERROR_NONE;
DeviceSettings* settings = malloc(sizeof(DeviceSettings));
DeviceSettings settings;
ds[i] = settings;
config_setting_t* config_device = config_setting_get_elem(config_devices, i);
const char* device_type;
@ -161,7 +164,7 @@ int main(int argc, char** argv)
if (error == MONOCOQUE_ERROR_NONE)
{
error = devsetup(device_type, device_subtype, device_config_file, ms, ds[i], config_device);
error = devsetup(device_type, device_subtype, device_config_file, ms, &ds[i], config_device);
}
if (error == MONOCOQUE_ERROR_NONE)
{
@ -175,20 +178,20 @@ int main(int argc, char** argv)
i = 0;
int j = 0;
error = MONOCOQUE_ERROR_NONE;
SimDevice* devices[numdevices];
while (i<configureddevices)
SimDevice* devices = malloc(numdevices * sizeof(SimDevice));
int initdevices = devinit(devices, configureddevices, ds);
if (p->program_action == A_PLAY)
{
if (ds[i]->is_valid == true)
slogi("running monocoque in gameloop mode..");
error = strtogame(p->sim_string, ms);
if (error != MONOCOQUE_ERROR_NONE)
{
SimDevice* device = malloc(sizeof(SimDevice));
devinit(device, ds[i]);
devices[j] = device;
j++;
}
i++;
goto cleanup_final;
}
error = looper(devices, numdevices, ms->sim_name);
error = looper(devices, initdevices, ms->sim_name);
if (error == MONOCOQUE_ERROR_NONE)
{
slogi("Game loop exited succesfully with error code: %i", error);
@ -197,26 +200,22 @@ int main(int argc, char** argv)
{
sloge("Game loop exited with error code: %i", error);
}
i = 0;
while (i<configureddevices)
{
if(ds[i]->dev_subtype == SIMDEV_USB)
{
free(ds[i]->tachsettings.pulses_array);
free(ds[i]->tachsettings.rpms_array);
}
free(ds[i]);
i++;
else
{
slogi("running monocoque in test mode...");
error = tester(devices, initdevices);
if (error == MONOCOQUE_ERROR_NONE)
{
slogi("Test exited succesfully with error code: %i", error);
}
else
{
sloge("Test exited with error code: %i", error);
}
}
i = 0;
while (i<numdevices)
{
devfree(devices[i]);
free(devices[i]);
i++;
}
devfree(devices, initdevices);
}