Update of /cvsroot/playerstage/code/player/client_libs/libplayerc/test
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22583/client_libs/libplayerc/test
Added Files:
test_aio.c test_dio.c test_speech.c
Log Message:
applied patch 1693851
--- NEW FILE: test_speech.c ---
/***************************************************************************
* Desc: Tests for the speech device
* Author: Alexis MAldonado
* Date: 4 May 2007
**************************************************************************/
#include <unistd.h>
#include "test.h"
#include "playerc.h"
// Just write something to a speech device.
int test_speech(playerc_client_t *client, int index)
{
int t;
void *rdevice;
playerc_speech_t *device;
printf("device [speech] index [%d]\n", index);
device = playerc_speech_create(client, index);
TEST("subscribing (read/write)");
if (playerc_speech_subscribe(device, PLAYER_OPEN_MODE) < 0)
{
FAIL();
return -1;
}
PASS();
TEST1("writing data (attempt %d)",1);
unsigned char text[]="Hello World!";
if (playerc_speech_say(device, text ) != 0) {
FAIL();
} else {
PASS();
}
usleep(1000000); //some time to see the effect
TEST1("writing data (attempt %d)",2);
unsigned char
text2[]="12345678901234567890123456789012345678901234567890";
TEST1("Printing: %s",text2);
if (playerc_speech_say(device, text2 ) != 0) {
FAIL();
} else {
PASS();
}
usleep(1000000); //some time to see the effect
TEST("unsubscribing");
if (playerc_speech_unsubscribe(device) != 0)
{
FAIL();
return -1;
}
PASS();
playerc_speech_destroy(device);
return 0;
}
--- NEW FILE: test_dio.c ---
/***************************************************************************
* Desc: Tests for the dio device
* Author: Alexis Maldonado
* Date: 3 May 2007
**************************************************************************/
#include <unistd.h>
#include "test.h"
#include "playerc.h"
// Basic test for an dio device.
int test_dio(playerc_client_t *client, int index) {
int t;
void *rdevice;
playerc_dio_t *device;
printf("device [dio] index [%d]\n", index);
device = playerc_dio_create(client, index);
TEST("subscribing (read/write)");
if (playerc_dio_subscribe(device, PLAYER_OPEN_MODE) < 0) {
FAIL();
return -1;
}
PASS();
for (t = 0; t < 5; t++) {
TEST1("reading data (attempt %d)", t);
do
rdevice = playerc_client_read(client);
while (rdevice == client);
if (rdevice == device) {
PASS();
printf("dio: [%8.3f] MSB...LSB:[ ",
device->info.datatime);
int i=0;
//printf("%d : ",device->digin);
for (i=0 ; i != device->count ; i++) {
//Extract the values of the single bits (easier on the eyes)
int dix=(device->digin & ( 1<<(device->count-(i+1)) ) )? 1 : 0 ;
printf("%1d",dix);
if (((i+1) % 4)==0) {
printf(" ");
}
}
printf("]\n");
}
else {
//printf("error: %s", playerc_error_str());
FAIL();
break;
}
}
unsigned int do_value=0;
const unsigned int do_count=8;
for (t = 0; t < 5; t++) {
TEST1("writing data (attempt %d)", t);
TEST1(" DO Value: %d",do_value);
do_value++;
if (playerc_dio_set_output(device, do_count, do_value ) != 0) {
FAIL();
break;
}
PASS();
usleep(200000); //some time to see the effect
}
//turn everything off:
do_value=0;
playerc_dio_set_output(device, do_count, do_value );
TEST("unsubscribing");
if (playerc_dio_unsubscribe(device) != 0) {
FAIL();
return -1;
}
PASS();
playerc_dio_destroy(device);
return 0;
}
--- NEW FILE: test_aio.c ---
/***************************************************************************
* Desc: Tests for the aio device
* Author: Alexis Maldonado
* Date: 3 May 2007
**************************************************************************/
#include <unistd.h>
#include "test.h"
#include "playerc.h"
// Just read from a aio device.
int test_aio(playerc_client_t *client, int index)
{
int t;
void *rdevice;
playerc_aio_t *device;
printf("device [aio] index [%d]\n", index);
device = playerc_aio_create(client, index);
TEST("subscribing (read/write)");
if (playerc_aio_subscribe(device, PLAYER_OPEN_MODE) < 0)
{
FAIL();
return -1;
}
PASS();
for (t = 0; t < 5; t++)
{
TEST1("reading data (attempt %d)", t);
do
rdevice = playerc_client_read(client);
while (rdevice == client);
if (rdevice == device)
{
PASS();
printf("aio: [%8.3f] AI0,...,AI7: [%5.3f] [%5.3f] [%5.3f] [%5.3f]
[%5.3f] [%5.3f] [%5.3f] [%5.3f]\n",
device->info.datatime, device->voltages[0],
device->voltages[1],device->voltages[2],device->voltages[3],device->voltages[4],device->voltages[5],device->voltages[6],device->voltages[7]);
}
else
{
//printf("error: %s", playerc_error_str());
FAIL();
break;
}
}
TEST("unsubscribing");
if (playerc_aio_unsubscribe(device) != 0)
{
FAIL();
return -1;
}
PASS();
playerc_aio_destroy(device);
return 0;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit