forked from waynix/SPinGW
-
Notifications
You must be signed in to change notification settings - Fork 1
SerialPort for MinGW
gotnone/SPinGW
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This Repository contains a wrapper to access the SerialPort in MinGW. Website:http://r0sset.com/Projects/24 Dependencies: Windows (tested under XP and 7) MinGW (not tested with Visual Studio and Cygwin) Usage: 1. Copy or fork SPinGW 2. Include serialport.h and serialport.c to your program. 3. Call openSerialPort from your program. 4. Use writeToSerialPort and readFromSerialPort to transfer data 5. Close the port with closeSerialPort when the communication is finished example.c: #include <stdio.h> #include "serialport.h" int main(void) { HANDLE h = openSerialPort("COM5",B9600,one,off); char sendbuffer[] = "test"; char readbuffer[100]; //write test int bytesWritten = writeToSerialPort(h,sendbuffer,strlen(sendbuffer)); printf("%d Bytes were written\n",bytesWritten); //read something int bytesRead = readFromSerialPort(h,readbuffer,99); readbuffer[bytesRead]=0; printf("%d Bytes were read:%s\n",bytesRead,readbuffer); closeSerialPort(h); return 0; } 6. compile gcc example.c serialport.c -o example.exe FAQ: Comports with a bigger number (I believe bigger than 9) can be used by with their UNC Paths \\\\.\\COM11 (thanks to jaui)
About
SerialPort for MinGW
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- C 100.0%