C++ builder 6 pros need help

Hoi Crossfire,

I'm a student in network & development. My group project is a Weather report Station.

My job in this project at the moments is to develop an application to link the card with a server ( database....). The link is made by RS232,baud rate no parity etc.

So before my mate finished the card i have to train on a GPS captor.


I'm working with C++ builder 6, installed the Tcomport api to communicate with RS232 link.

The connexion between the computer and the captor has been succesfull, so now i have to manage to filter the nmea frames.

Every frames are sent every seconds, the thing is the code i created, provides only GPRMS frames from the captor, and seems to bug after a few seconds.

Giving the source code if anybodys sees any mistake, I would like to have some advice about the rxchar part from the code.

Thanks in advance.

description :
My problem is located on the ComPort1RxChar part :

variables : dollar is to take the $ which is the beginning of a nmea frame.
etoile is to take the end of the frame "*".
longTrame is the length
The problem might be in the condition "if.....{}" but i can't find what makes me get only a few part of the datas.


Quote by source code


#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "CPort"
#pragma resource "*.dfm"
AnsiString Trame;
int flagTrame;

TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
ComPort1->Connected=true;//Ouverture du port COM3
Label1->Caption="Port COM3 ouvert";
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
ComPort1->Connected=false;//Fermeture du port COM3
Label1->Caption="Port COM3 fermé";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComPort1RxChar(TObject *Sender, int Count)
{
AnsiString TrameRecue;
ComPort1->ReadStr(TrameRecue, Count);//Lecture de la trame sur le port COM

if (CheckBox1->Checked == true)
{


//recherche de $ et * dans la chaine recue
int dollar=TrameRecue.AnsiPos("$");
int etoile=TrameRecue.AnsiPos("*");
int longTrame=TrameRecue.Length();


//phase de test si presence des caracteres recherchés


if (dollar!=0)
{
Trame=TrameRecue.SubString(dollar,longTrame);
flagTrame=1;
}
else
{
if ((etoile==0)&&(flagTrame==1))
{
Trame =Trame + TrameRecue;
//Memo1->Lines->Add("ddd");
}

if ((etoile==1)&&(flagTrame==1))
{
TrameRecue=TrameRecue.SubString(1,etoile);
Trame=Trame+TrameRecue;
Memo1->Lines->Add(Trame);
flagTrame = 0;

}
}
}
else
{ Memo1->Lines->Add(TrameRecue);
}


}
//---------------------------------------------------------------------------



void __fastcall TForm1::FormCreate(TObject *Sender)
{
Label1->Caption="";
}





image: tumblr_kznp8oLbkT1qzy9ouo1_500
Comments
7
Learn C++

Code Hacks
learning C++, hack coding is useless
alrdy 2 high
Parent
hack coding isn't useless
Parent
va baiser des putes et ton projet se realisera
serious nerd shit
Back to top