| | |
Help writing a simple Ymodem Send
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 1
Reputation:
Solved Threads: 0
Hey there, I'm fairly new to programming but have been tasked with writing a Ymodem send program to send some data that I parsed out to hardware. So far I have parsed data into a char array, and then opened up a serial port. I just don't know where to begin in writing a Ymodem send program (the receiving end was written by someone else). Here is my code for opening the serial port, now I am stuck in implementing the actual Ymodem protocol. I have searched for code online but most of it makes use of extra libraries that I don't have. I am currently writing this in Visual C++ . Any help would be greatly appreciated, Thanks!
C++ Syntax (Toggle Plain Text)
#include "stdafx.h" #include "windows.h" #include "string.h" #include "stdio.h" #include "ymodem.h" HANDLE hComPort; BOOL SetCommDefaults(HANDLE hSerial); int main() { hComPort = CreateFile("\\\\.\\COM24", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); if (hComPort == INVALID_HANDLE_VALUE){ return FALSE; SetCommDefaults(hComPort); printf("E012_Failed to open port"); }else{ SetCommDefaults(hComPort); DWORD dwBytesRead =0; DWORD dwBytesWritten =1; char buf[50]; sprintf(buf,"I am connected to hyperterminal\n"); WriteFile(hComPort, buf, strlen(buf), &dwBytesWritten,NULL); } CloseHandle(hComPort); return 0; } BOOL SetCommDefaults(HANDLE hComPort) { DCB dcb; dcb.BaudRate = 115200; dcb.ByteSize = 8; dcb.Parity = 0; dcb.StopBits = ONESTOPBIT; dcb.fDtrControl = DTR_CONTROL_DISABLE; dcb.fDtrControl = RTS_CONTROL_DISABLE; if(!SetCommState(hComPort, &dcb)) return FALSE; return TRUE; }
![]() |
Other Threads in the C++ Forum
- Previous Thread: Form Is Scrolling Down
- Next Thread: Problems parsing arguments.
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number output parameter pointer problem program programming project python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector visualstudio win32 windows winsock word wordfrequency wxwidgets





