Hi there !
I’m french and i’m in charge of a Robotic School Project.
It’s from a novice level , and i must control the SSC32 (with the Lynx Motion 6) from a specific controller ( a DK40 from Beck )
The hardware that i used is :
-A DK41 Kit ( beck-ipc.com/ipc/application … .asp?sp=en )
-The LynxMotion 6 pack with the SSC32 card and his connectivity cable
I’m actually able to recieve and send instruction to a PC connected to the DK40 via serial connection, but when i try to make the same thing on the SSC32, there’s no result…
The test program that i copy/past here is build with DK40 proper function, and work when the target is a PC.
/******************************************************************************
* Includes
******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "clib.h"
/******************************************************************************
* Affiche la liste de commande
******************************************************************************/
void usage( void )
{
printf( "\r\n Envoi de caracteres"
"\r\nPour utiliser: LAN3x [port] [data] [parite] [stop] [flow] [debit] "
#ifdef SC123
"\r\n port: 0=EXT, 1=COM, 2=SER2, 3=SER3"
#else
"\r\n port: 0=EXT, 1=COM"
#endif
"\r\n data: 7, 8"
"\r\n parite: N, E, O, M, S"
"\r\n stop: 1, 2"
"\r\n flow: 0=No, 1=RTS/CTS 2=XON/XOFF"
"\r\n debit: baudrate"
"\r\n"
"\r\n NOTE: 2 bits de stop ne sont disponible uniquement si il n'y a aucun parite."
"\r\n Controle de flux (flow) uniquement pour rs485." );
exit( 1 );
}
/******************************************************************************
* main()
******************************************************************************/
void main (int argc, char *argv])
{
char chr = 0; // Caractere recu par le port serie COM
unsigned int i = 0, // Compteurs
j = 0,
// Parametres pour la configuration du port serie
bits = 0,
parity = 0,
stop = 0,
port = 0,
flow = 0,
divisor = 0;
unsigned long baud = 0l,
maxbaud = 0l; // Debit en Bauds maximum par le CPU
char instruction1[20] = "#0P2000"; // Chaine envoyer au port serie EXT
char instruction2[20] = "#0P1600";
// Obtenir le debit max en Bauds
maxbaud = hal_get_frequencies( GET_FRQ_MAX_BAUD );
// Configuration du port selon les arguments passer
if( argc >= 7 )
{
port = atoi(argv[1]);
#ifdef SC123
if( port > 3 )
#else
if( port > 1 )
#endif
usage();
bits = atoi(argv[2]);
if ((bits<7) || (bits>8))
usage();
chr = argv[3][0];
switch (chr)
{
case 'N':
case 'n':
parity=0;
break;
case 'O':
case 'o':
parity=1;
break;
case 'E':
case 'e':
parity=2;
break;
case 'M':
case 'm':
parity=3;
break;
case 'S':
case 's':
parity=4;
break;
default:
usage();
}
stop = atoi(argv[4]);
if ((stop<1) || (stop>2))
usage();
if ((parity) && (stop==2))
usage();
flow = atoi(argv[5]);
if (flow>2)
usage();
baud = atol( argv[6] );
}
else
{
usage();
}
// Le diviseur de l'horloge
divisor = (unsigned int)((2*maxbaud) / baud);
divisor++;
divisor >>= 1; //Decalage
// Affiche les parametre d'i_nitialisation
printf("\r\nInititalisation : port%d with %d%c%d and %lu baud",
port, bits, toupper(chr), stop, baud);
printf("\r\nDiviseur de : %d\r\n",divisor);
// initialise le module fossil
if( fossil_init( port ) != 0x1954 )
{
printf("\r\nEchec de l'initialisation\r\n");
return;
}
// Initalise le debit en Bauds
fossil_set_extctrl( port, divisor, parity, bits, stop );
// initialise le controle de Flux
if (flow)
{
printf("\r\nUsing %s flow control\r\n", (flow==1) ? "RTS/CTS" : "XON/XOFF");
if (flow == 1) // RTS/CTS
fossil_set_flowcontrol( port, FOSSIL_FLOWCTRL_RTSCTS );
if (flow == 2) // XON/XOFF
fossil_set_flowcontrol( port, FOSSIL_FLOWCTRL_XONXOFF_SEND_RECV );
}
// Activation et Purge des Tempons
fossil_purge_output( port );
fossil_purge_input( port );
/************************** Debut du transfert 1 !****************************/
// transfer block et lire
for( j = 0; j < strlen( instruction1 ); )
{
j += fossil_writeblock( port, (unsigned char *)instruction1 + j, strlen( instruction1 ) - j );
/*
// Lit un bloc de 1 caractere
if( fossil_readblock( port, (unsigned char *)&chr, 1 ) )
{
putchar(chr);
}
*/
RTX_Sleep_Time( 100 );
}
/*********************************Fin transfert instruction 1********/
/***************PAUSE***********************************************/
printf("\r\nEn attente d'appuie sur une touche pour envoyer l'instruction 2// Waiting from keyboard");
BIOS_getch() ;
/*********************FIN PAUSE*************************************/
fossil_purge_output( port );
fossil_purge_input( port );
/*******************Debut transfert Instruction 2*******************/
for( j = 0; j < strlen( instruction2 ); )
{
j += fossil_writeblock( port, (unsigned char *)instruction2 + j, strlen( instruction2 ) - j );
// Lit un bloc de 1 caractere
// if( fossil_readblock( port, (unsigned char *)&chr, 1 ) )
// {
// putchar(chr);
// }
RTX_Sleep_Time( 100 );
}
/************************** Fin insctruction 2 *******************************/
// desinitialise fossil
fossil_deinit( port );
printf("\r\nTerminer");
}
// EOF
The first part of the soft is just for the serial connection configuration the other part with the writeblock function is the transfer of the string “instruction” define on the top of the code.
Does anyone have an idea of why the soft work with a PC target but not with the SSC32 ?
PS : I already check the forum for reponses and i’m currently using my soft with no flow control ,no parity ,1 stop ,115200 baudrate
And another question, does anyone know where i can find a C++ example for the SSC32 ? :s