Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
Removed old code
  • Loading branch information
tnightingale committed Oct 1, 2010
1 parent 83a3404 commit 8b2c2ff
Show file tree
Hide file tree
Showing 5 changed files with 313 additions and 12 deletions.
64 changes: 64 additions & 0 deletions application.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
/*------------------------------------------------------------------------------------------------------------------
-- SOURCE FILE: application.c - Handles visual presentation functionality.
--
-- PROGRAM: dte
--
-- Functions:
-- void printOut(PWDATA pWData, HDC hdc)
-- void setMenu(HMENU menu, UINT uEnable)
--
-- DATE: September 29th 2010
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Tom Nightingale
--
-- PROGRAMMER: Tom Nightingale
--
-- NOTES: Prints data stored in the data string (pWData->output.out) to display area. Handles formatting,
-- newlines, etc. Math could do with a bit of work.
--
----------------------------------------------------------------------------------------------------------------------*/

#include "application.h"
#include "session.h"

/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: printOut
--
-- DATE: September 29th, 2010
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Tom Nightingale
--
-- PROGRAMMER: Tom Nightingale
--
-- INTERFACE: printOut(PWDATA pWData, HDC hdc)
-- PWDATA pWData: Program's window data storage struct containing the buffer string (output) and it's
-- metadata.
-- HDC hdc: Hardware device controller.
--
-- RETURNS: void.
--
-- NOTES: Prints data stored in the data string (pWData->output.out) to display area. Handles formatting,
-- newlines, etc. Math could do with a bit of work.
--
----------------------------------------------------------------------------------------------------------------------*/
void printOut(PWDATA pWData, HDC hdc) {
TEXTMETRIC tm;
HFONT hFont;
Expand Down Expand Up @@ -29,6 +73,26 @@ void printOut(PWDATA pWData, HDC hdc) {
}
}

/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: setMenu
--
-- DATE: September 29th, 2010
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Tom Nightingale
--
-- PROGRAMMER: Tom Nightingale
--
-- INTERFACE: setMenu(HMENU menu, UINT uEnable
-- HMENU menu: A win32 menu struct returned by GetMenu().
-- UINIT uEnable: Option to be passed to EnableMenuItem. The setting to apply to the menu.
--
-- RETURNS: void.
--
-- NOTES: Sets all of the menu items to the value of uEnable.
--
----------------------------------------------------------------------------------------------------------------------*/
void setMenu(HMENU menu, UINT uEnable) {
EnableMenuItem(menu, IDM_CONNECT, uEnable);
EnableMenuItem(menu, IDM_COM1, uEnable);
Expand Down
83 changes: 83 additions & 0 deletions datalink.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
/*------------------------------------------------------------------------------------------------------------------
-- SOURCE FILE: datalink.c - Contains functions that directly interact with the serial port.
--
-- PROGRAM: dte
--
-- Functions:
-- HANDLE OpenPort(LPCWSTR)
-- int Transmit(HANDLE, TCHAR)
-- BOOL Recieve(HANDLE, TCHAR*)
--
-- DATE: September 29th 2010
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Tom Nightingale
--
-- PROGRAMMER: Tom Nightingale
--
-- NOTES: Functions to create, transmit and recieve raw data on the port.
--
----------------------------------------------------------------------------------------------------------------------*/

#include "datalink.h"

/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: OpenPort
--
-- DATE: September 29th, 2010
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Tom Nightingale
--
-- PROGRAMMER: Tom Nightingale
--
-- INTERFACE: OpenPort(LPCWSTR lpFileName)
-- LPCWSTR lpFileName: The name of the port to open.
--
-- RETURNS: HANDLE: Handle to open port.
--
-- NOTES: Opens desired port, returns invalid handle if failed.
--
----------------------------------------------------------------------------------------------------------------------*/
HANDLE OpenPort(LPCWSTR lpFileName) {
HANDLE hCom;
DWORD err;
Expand Down Expand Up @@ -30,6 +71,27 @@ HANDLE OpenPort(LPCWSTR lpFileName) {
return hCom;
}


/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: Transmit
--
-- DATE: September 29th, 2010
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Tom Nightingale
--
-- PROGRAMMER: Tom Nightingale
--
-- INTERFACE: Transmit(HANDLE hCom, TCHAR c)
-- HANDLE hCom: The handle to write to.
-- TCHAR c: The character to transmit.
--
-- RETURNS: int: 1 if error, 0 on success.
--
-- NOTES: Writes char to port.
--
----------------------------------------------------------------------------------------------------------------------*/
int Transmit(HANDLE hCom, TCHAR c) {
DWORD dwBytesToWrite = 1;
DWORD dwBytesWritten = 0;
Expand All @@ -44,6 +106,27 @@ int Transmit(HANDLE hCom, TCHAR c) {
return 0;
}


/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: Receive
--
-- DATE: September 29th, 2010
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Tom Nightingale
--
-- PROGRAMMER: Tom Nightingale
--
-- INTERFACE: Recieve(HANDLE hCom, TCHAR* readBuff)
-- HANDLE hCom: The handle to write to.
-- TCHAR*: A buffer to contain recieved char.
--
-- RETURNS: FALSE on error, TRUE on success.
--
-- NOTES: Reads from open port and writes chars to buffer.
--
----------------------------------------------------------------------------------------------------------------------*/
BOOL Recieve(HANDLE hCom, TCHAR* readBuff) {
DWORD dwBytesToRead = 1;
DWORD dwBytesRead = 0;
Expand Down
44 changes: 44 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
/*------------------------------------------------------------------------------------------------------------------
-- SOURCE FILE: main.c - Contains WinMain, initializes the program.
--
-- PROGRAM: dte
--
-- Functions:
-- int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hprevInstance, LPSTR lspszCmdParam, int nCmdShow)
--
-- DATE: September 29th 2010
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Tom Nightingale
--
-- PROGRAMMER: Tom Nightingale
--
-- NOTES: Contains win32 main program initializing function WinMain(). Initiates message loop and handles
-- calling dispatch on the messages.
--
----------------------------------------------------------------------------------------------------------------------*/

#include "main.h"
#include "session.h"


/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: WinMain
--
-- DATE: September 29th, 2010
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Tom Nightingale
--
-- PROGRAMMER: Tom Nightingale
--
-- INTERFACE: WinMain(HINSTANCE hInst, HINSTANCE hprevInstance, LPSTR lspszCmdParam, int nCmdShow)
-- HINSTANCE hInst
-- HINSTANCE hprevInstance
-- LPSTR lspszCmdParam
-- int nCmdShow
--
-- RETURNS: WINAPI.
--
-- NOTES:
--
----------------------------------------------------------------------------------------------------------------------*/
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hprevInstance, LPSTR lspszCmdParam, int nCmdShow) {
HWND hwnd;
MSG Msg;
Expand Down
Loading

0 comments on commit 8b2c2ff

Please sign in to comment.