Hej, mam problem chyba z buforem, napiselem kod w Borlandzie i efekt jest taki, ze jak odpale moj program 2 razy (z 1 wysylam, drugim odbieram przez nullmodem) to jak wysle np 12345 to odbiore 12345, ale jak zaraz potem wysle cos krotszego np xx to odbiore xx345. Co robie nie tak?
pozdrawiam, ponizej fragmrent kodu dla wysylania:
void __fastcall TForm1::Button1Click(TObject *Sender) { DWORD NumberOfBytesWritten; char* text[20]; fdwEvtMask = EV_TXEMPTY; //ze wyslano ostatni znak
EscapeCommFunction(hCommDev, SETRTS); WriteFile(hCommDev, (Edit5->Text).c_str(), (Edit5->Text).Length(), &NumberOfBytesWritten, NULL); WaitCommEvent(hCommDev, &fdwEvtMask, NULL); Edit5->Text = ""; FlushFileBuffers(hCommDev); //PurgeComm(hCommDev, PURGE_TXCLEAR);
EscapeCommFunction(hCommDev, CLRRTS);
}i odbierania: void __fastcall TForm1::Button2Click(TObject *Sender) { Edit6->Text = ""; char dummytab[cbInQueue] = ""; strcpy(Buffer_I, dummytab); Read_Comm(hCommDev, Buffer_I, &Number_Bytes_Read, sizeof(Buffer_I)); Edit6->Text = Buffer_I;
}