hello i have a problem with the pololu code writing, he is working without errors but the controller is not responding.
I think that im not writing right in the pololu mode.
can some one help me please?
/* ------------------------------------------------------------------------ --
-- --
-- Application example for using Tserial_event --
-- --
-- --
-- --
-- Copyright @ 2001-2002 Thierry Schneider --
-- thierry@tetraedre.com --
-- --
-- --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Filename : serialtest.cpp --
-- Author : Thierry Schneider --
-- Created : April 8th 2001 --
-- Modified : January 30th 2002 --
-- Plateform: Windows 95, 98, NT, 2000 (Win32) --
-- ------------------------------------------------------------------------ --
-- --
-- This software is given without any warranty. It can be distributed --
-- free of charge as long as this header remains, unchanged. --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- 01.04.24 # ifdef __BORLANDC__ added in the header --
-- --
-- 02.01.30 Version 2.0 of the serial event object --
-- --
-- --
-- ------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------- */
#ifdef __BORLANDC__
#pragma hdrstop // borland specific
#include <condefs.h>
#pragma argsused
USEUNIT("Tserial_event.cpp");
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
#include "conio.h"
#include "Tserial_event.h"
#include "windows.h"
/* ======================================================== */
/* =============== OnCharArrival ===================== */
/* ======================================================== */
void OnDataArrival(int size, char *buffer)
{
if ((size>0) && (buffer!=0))
{
buffer[size] = 0;
printf("OnDataArrival: %s ",buffer);
}
}
/* ======================================================== */
/* =============== OnCharArrival ===================== */
/* ======================================================== */
void SerialEventManager(uint32 object, uint32 event)
{
char *buffer;
int size;
Tserial_event *com;
com = (Tserial_event *) object;
if (com!=0)
{
switch(event)
{
case SERIAL_CONNECTED :
printf("Connected ! \n");
break;
case SERIAL_DISCONNECTED :
printf("Disonnected ! \n");
break;
case SERIAL_DATA_SENT :
printf("Data sent ! \n");
break;
case SERIAL_RING :
printf("DRING ! \n");
break;
case SERIAL_CD_ON :
printf("Carrier Detected ! \n");
break;
case SERIAL_CD_OFF :
printf("No more carrier ! \n");
break;
case SERIAL_DATA_ARRIVAL :
size = com->getDataInSize();
buffer = com->getDataInBuffer();
OnDataArrival(size, buffer);
com->dataHasBeenRead();
break;
}
}
}
/* ======================================================== */
/* ======================== main ======================= */
/* ======================================================== */
int main(int argc, char* argv[])
{
int c,d;
int erreur;
char a[8];
char b[4];
Tserial_event *com;
c=0;
d=0;
[b] a[0]=128;
a[1]=1;
a[2]=4;
a[3]=6;
a[4]=19;
a[5]=136;
// a[6]=0;
a[6]='\0';
[/b]
//printf("haim ata ahabal %s\n ", a);
//printf("%s\n ", b);
scanf("%d\n ", c);
printf("%d\n ", c);
//a[2]=c;
printf("%s\n ", a);
scanf("%d\n ", d);
printf("%d\n ", d);
b[2]=d;
printf("%s\n ", b);*/
com = new Tserial_event();
if (com!=0)
{
com->setManager(SerialEventManager);
erreur = com->connect("COM1", 9600, SERIAL_PARITY_NONE, 8, true);
if (!erreur)
{
while(1){
a[3]=21;
a[4]=124;
com->sendData(a,strlen(a)+1);
printf("d");
// Sleep(1);
com->sendData(b,strlen(b)+1);
Sleep(1000);
a[2]=0;
com->sendData(a,strlen(a)+1);
Sleep(1000);
Sleep(1000);
b[2]=0;
com->sendData(b,strlen(b)+1);
Sleep(1000);
com->setRxSize(1);
}
}
else
printf("ERROR : com->connect (%ld)\n",erreur);
// ------------------
com->disconnect();
// ------------------
delete com;
com = 0;
}
return 0;
}