ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
447
447
EMPFEHLEN
-
07.04.09 12:59 #1
- Registriert seit
- Mar 2009
- Beiträge
- 24
moin...
habe eine Frage: wie kann ich einen String per serielle schnitstelle an com1 (vom Laptop) bzw. an den damit verbundenen desktop-pc schicken?
ich habe die schnittstelle bereits initialisiert, finde jedoch nicht heraus wie ich etwas senden kann...?
Kennt jemand ein Programm, welches anzeigt was auf den com-SS anliegt?
anschliessend noch mein code...hoffe dass ihr mir helfen könnt....kann mein problem ansonsten noch anders erleutern...PHP-Code://RS 232-Schnittstelle (seriell)
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <windows.h>
using namespace std;
char meldung[50];
int main(int argc, char *argv[])
{
unsigned int value;
HANDLE hCom;
DCB ComSettings;
DWORD write,written;
ZeroMemory(&ComSettings, sizeof(DCB));
ComSettings.DCBlength = sizeof(DCB);
ComSettings.BaudRate = CBR_115200;
ComSettings.fBinary = 1;
ComSettings.fTXContinueOnXoff = 1;
ComSettings.ByteSize = 8;
ComSettings.Parity = NOPARITY;
ComSettings.StopBits = ONESTOPBIT;
hCom = CreateFile( "COM1",
GENERIC_READ | GENERIC_WRITE,
0, // must be opened with exclusive-access
NULL, // default security attributes
OPEN_EXISTING, // must use OPEN_EXISTING
0, // not overlapped 1/O
NULL // hTemplate must be NULL for comm devices
);
if (hCom == INVALID_HANDLE_VALUE)
{
cout << "COM1 konnte nicht geoeffnet werden." << endl << endl;
}
else
{
cout << "COM1 wurde erfolgreich geoeffnet." << endl;
if (SetCommState(hCom,&ComSettings))
{
cout << "COM1 wurde erfolgreich initialisiert." << endl << endl;
while(1)
{
cout << "Textmeldung auf Terminal senden: \n";
scanf("%s",meldung);
[COLOR="Red"] HIER KÄHME JETZT DER WRITE BEFEHL!
HIER MEIN ANSATZ:[/COLOR]
/*if (!WriteFile(ComPort,meldung,write,&written,NULL))
cout << "Error" << endl;*/
}
}
else
{
cout << "COM1 konnte nicht initialisiert werden." << endl << endl;
cout << "LastError: " << GetLastError() << endl;
}
}
system("pause");
return EXIT_SUCCESS;
}
Ähnliche Themen
-
RS232 Kommunikation
Von TheTank im Forum VisualStudio & MFCAntworten: 10Letzter Beitrag: 03.09.10, 08:34 -
RS232 Kommunikation mit Java
Von nougs im Forum JavaAntworten: 2Letzter Beitrag: 09.07.09, 14:50 -
C# RS232 Kommunikation
Von ibabak im Forum .NET Web und KommunikationAntworten: 1Letzter Beitrag: 17.12.07, 15:23 -
RS232 Kommunikation
Von alma im Forum .NET ArchivAntworten: 2Letzter Beitrag: 03.09.04, 07:36 -
RS232 Kommunikation unter c#
Von RioT im Forum .NET ArchivAntworten: 1Letzter Beitrag: 30.03.04, 14:23





Zitieren
Login






