C++ HypeTerminal
hi leute heute ist mein erster arbeitstag als azubi anwednungsentwickler. ich habe ne "kleine" aufgabe bekommen doch ich komme nicht klar. ich arbeite hier mit Borland Builder6 und muss ein programm schreiben welches text an unterschiedliche HyperTerminals versendet. Diese HyperTerminals sind irgendwas von COM oder so habe total keine ahnung davon. hinten am pc sind da so 2 anschlüsse die sind mit einem kabel verbunden wenn cih in den bildschirm von einem der HyperTerminals was eintippe erschein der text bei dem anderen Terminal und ich muss ein programm halt haben wo ich was eintippe aussuche an welchen Terminal es geschickt wird und absenden. da brauche ich mal eure hilfe
MFG
MFG
Mein kleines Projekt
-Cruel Online-
-Cruel Online-
problem gelößt hier ist die lösung falls es jemanden interessiert

|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
DCB sDcb;
HANDLE hFile;
COMMTIMEOUTS sTo;
switch (rg->ItemIndex)
{
case 0:
{
hFile=CreateFile("\\\\.\\COM1",GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0) ;
break;
}
case 1:
{
hFile=CreateFile("\\\\.\\COM2",GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0) ;
break;
}
}
if(hFile==INVALID_HANDLE_VALUE)return;
memset(&sDcb,0,sizeof(sDcb));
sDcb.DCBlength = sizeof(sDcb);
sDcb.BaudRate = 9600; // Baudrate
sDcb.fParity = FALSE;
sDcb.fBinary = TRUE;
sDcb.Parity = NOPARITY;// Kein Paritybit
sDcb.StopBits = ONESTOPBIT;
sDcb.fOutxCtsFlow = FALSE;
sDcb.fOutxDsrFlow = FALSE;
sDcb.fDtrControl = DTR_CONTROL_ENABLE;
sDcb.fRtsControl = RTS_CONTROL_ENABLE; +
sDcb.fDsrSensitivity = FALSE;
sDcb.fAbortOnError = FALSE;
sDcb.ByteSize = 8; // 8 Datenbits
if(!SetCommState(hFile,&sDcb))
{
CloseHandle(hFile);
return;
}
sTo.ReadIntervalTimeout = MAXDWORD; // 0 ms Read-Tomeout
sTo.ReadTotalTimeoutMultiplier = 0;
sTo.ReadTotalTimeoutConstant = 0;
sTo.WriteTotalTimeoutMultiplier= 1; // 1*2 ms Write Timeout
sTo.WriteTotalTimeoutConstant = 2;
if(!SetCommTimeouts((HANDLE)hFile,&sTo))
{
CloseHandle(hFile);
return;
}
DWORD dwCount;
char* test = new char[ Edit1->Text.Length() + 1 ];
strcpy( test, Edit1->Text.c_str());
WriteFile(hFile,test,Edit1->Text.Length(),&dwCount,0);
CloseHandle(hFile);
|
Mein kleines Projekt
-Cruel Online-
-Cruel Online-


