tdf_tty.c - TDF TTY program
A useful little utility to snarf a Signal data
stream from a serial port, save the quotes and broadcast a
data stream out the Ethernet to other clients.
The serial port code comes from a Microsoft SDK sample TTY.C
which I have layeried my code on top of. Warning - the SIG_DATA.C
module does not claim to handle all of the Signal data stream.
I do not have the Signal SDK, this is a simple example which
will grab most things (futures, mutual funds, stocks, indexes +
market messages & time stamps). If you expand that code or have
further info on the data stream, I'd be interested in seeing it.
This program is also a good example of using the udp socket
module to broadcast data to other programs on your LAN. It
also demos the use of the DeBug Message PORT routines
(DBM_PORT.C) for leaving embedded debug code in shipping apps.
Function
|
WinMain
|
Include file
|
TDF_TTY.H
|
Prototype
|
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow )
|
Remarks
|
Main program entry point.
|
Function
|
InitApplication
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR InitApplication( HANDLE hInstance )
|
Remarks
|
First time initialization stuff.
|
Function
|
InitInstance
|
Include file
|
TDF_TTY.H
|
Prototype
|
HWND NEAR InitInstance( HANDLE hInstance, int nCmdShow )
|
Remarks
|
Initializes instance specific information.
|
Function
|
TTYWndProcOld
|
Include file
|
TDF_TTY.H
|
Prototype
|
LRESULT FAR PASCAL TTYWndProcOld( HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam )
|
Remarks
|
This is the TTY Window Proc.
|
Function
|
CreateTTYInfo
|
Include file
|
TDF_TTY.H
|
Prototype
|
LRESULT NEAR CreateTTYInfo( HWND hWnd )
|
Remarks
|
Creates the tty information structure and sets menu option availability.
Returns -1 if unsuccessful.
|
Function
|
DestroyTTYInfo
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR DestroyTTYInfo( HWND hWnd )
|
Remarks
|
Destroys block associated with TTY window handle.
|
Function
|
ResetTTYScreen
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR ResetTTYScreen( HWND hWnd, NPTTYINFO npTTYInfo )
|
Remarks
|
Resets the TTY character information and causes the screen to resize to update
the scroll information.
|
Function
|
PaintTTY
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR PaintTTY( HWND hWnd )
|
Remarks
|
Paints the rectangle determined by the paint struct of the DC.
|
Function
|
SizeTTY
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR SizeTTY( HWND hWnd, WORD wVertSize, WORD wHorzSize )
|
Remarks
|
Sizes TTY and sets up scrolling regions.
|
Function
|
ScrollTTYVert
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR ScrollTTYVert( HWND hWnd, WORD wScrollCmd, WORD wScrollPos )
|
Remarks
|
Scrolls TTY window vertically.
|
Function
|
ScrollTTYHorz
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR ScrollTTYHorz( HWND hWnd, WORD wScrollCmd, WORD wScrollPos )
|
Remarks
|
Scrolls TTY window horizontally.
|
Function
|
SetTTYFocus
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR SetTTYFocus( HWND hWnd )
|
Remarks
|
Sets the focus to the TTY window also creates caret.
|
Function
|
KillTTYFocus
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR KillTTYFocus( HWND hWnd )
|
Remarks
|
Kills TTY focus and destroys the caret.
|
Function
|
MoveTTYCursor
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR MoveTTYCursor( HWND hWnd )
|
Remarks
|
Moves caret to current position.
|
Function
|
ProcessTTYCharacter
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR ProcessTTYCharacter( HWND hWnd, BYTE bOut )
|
Remarks
|
This simply writes a character to the port and echos it to the TTY
screen if fLocalEcho is set.
|
Function
|
OpenConnection
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR OpenConnection( HWND hWnd )
|
Remarks
|
Opens communication port specified in the TTYINFO struct. It also sets the
CommState and notifies the window via the fConnected flag in the TTYINFO struct.
|
Function
|
SetupConnection
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR SetupConnection( HWND hWnd )
|
Remarks
|
This routines sets up the DCB based on settings in the TTY info structure
and performs a SetCommState().
|
Function
|
CloseConnection
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR CloseConnection( HWND hWnd )
|
Remarks
|
Closes the connection to the port. Resets the connect flag in the TTYINFO
struct.
|
Function
|
ReadCommBlock
|
Include file
|
TDF_TTY.H
|
Prototype
|
int NEAR ReadCommBlock( HWND hWnd, LPSTR lpszBlock, int nMaxLength )
|
Remarks
|
Reads a block from the COM port and stuffs it into the provided buffer.
|
Function
|
WriteCommBlock
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR WriteCommBlock( HWND hWnd, LPSTR lpByte , DWORD dwBytesToWrite)
|
Remarks
|
Writes a block of data to the COM port specified in the associated
TTY info structure.
|
Function
|
WriteTTYBlock
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR WriteTTYBlock( HWND hWnd, LPSTR lpBlock, int nLength )
|
Remarks
|
Writes block to TTY screen. Nothing fancy - just straight TTY.
|
Function
|
GoModalDialogBoxParam
|
Include file
|
TDF_TTY.H
|
Prototype
|
VOID NEAR GoModalDialogBoxParam( HINSTANCE hInstance, LPCSTR lpszTemplate,
HWND hWnd, DLGPROC lpDlgProc, LPARAM lParam )
|
Remarks
|
It is a simple utility function that simply performs the MPI and invokes the
dialog box with a DWORD paramter.
|
Function
|
AboutDlgProc
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL FAR PASCAL AboutDlgProc( HWND hDlg, UINT uMsg,
WPARAM wParam, LPARAM lParam )
|
Remarks
|
A simple dialog box proc to support an "about" box.
|
Function
|
FillComboBox
|
Include file
|
TDF_TTY.H
|
Prototype
|
VOID NEAR FillComboBox( HINSTANCE hInstance, HWND hCtrlWnd, int nIDString,
DWORD NEAR *npTable, WORD wTableLen,
DWORD dwCurrentSetting )
|
Remarks
|
Fills the given combo box with strings from the resource table starting at
nIDString. Associated items are added from given table. The combo box is
notified of the current setting.
|
Function
|
SettingsDlgInit
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR SettingsDlgInit( HWND hDlg )
|
Remarks
|
Puts current settings into dialog box (via CheckRadioButton() etc.)
|
Function
|
SelectTTYFont
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR SelectTTYFont( HWND hDlg )
|
Remarks
|
Selects the current font for the TTY screen. Uses the Common Dialog
ChooseFont() API.
|
Function
|
SettingsDlgTerm
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL NEAR SettingsDlgTerm( HWND hDlg )
|
Remarks
|
Puts dialog contents into the TTY info structure.
|
Function
|
SettingsDlgProc
|
Include file
|
TDF_TTY.H
|
Prototype
|
BOOL FAR PASCAL SettingsDlgProc( HWND hDlg, UINT uMsg,
WPARAM wParam, LPARAM lParam )
|
Remarks
|
Dialog Proc for setting all of the user preference settings for the TTY.
|
Function
|
CommWatchProc
|
Include file
|
TDF_TTY.H
|
Prototype
|
DWORD FAR PASCAL CommWatchProc( LPSTR lpData )
|
Remarks
|
A secondary thread that will watch for COMM events.
|
Function
|
snarf_the_bytes
|
Include file
|
TDF_TTY.H
|
Prototype
|
void snarf_the_bytes( LPSTR lpBlock, int nLength )
|
Remarks
|
Copy the ASCII data, NUKK terminate it then pass it to the store code.
|
Function
|
init_the_snarf_code
|
Include file
|
TDF_TTY.H
|
Prototype
|
void init_the_snarf_code( void )
|
Remarks
|
Clear the signal data collection vars.
|
Function
|
write_snarfed_data
|
Include file
|
TDF_TTY.H
|
Prototype
|
void write_snarfed_data( void )
|
Remarks
|
If the collection tree is dirty flush it to disk.
|
Function
|
init_1_broadcast_port
|
Include file
|
TDF_TTY.H
|
Prototype
|
IP_SOCK *init_1_broadcast_port( int port_num )
|
Remarks
|
Allocate, initialize, open and return to the caller a UDP broadcast socket
for his requested port number.
|
Function
|
init_broadcast_ports
|
Include file
|
TDF_TTY.H
|
Prototype
|
void init_broadcast_ports( void )
|
Remarks
|
Open all the broadcast ports for the application. (4 - raw data echo,
data quotes, market messages and time stamps.)
|
Function
|
free_the_snarf_code
|
Include file
|
TDF_TTY.H
|
Prototype
|
void free_the_snarf_code( void )
|
Remarks
|
Be nice and close the sockets before exiting.
|
Function
|
process_cmd_line_4_arguments
|
Include file
|
TDF_TTY.H
|
Prototype
|
void process_cmd_line_4_arguments( void )
|
Remarks
|
Process the user's command line arguments into a argv array which then is
processed by the normal getargs() procedure to store the data into the
programs switch flags.
|
Table of Contents
Function Index
generated on 22 September 1998 - 12:55:48
© 1998 Tierra del Fuego Ltd.
|