Page 121
TCHAR szTitle[] = TEXT("Example 1 (U)"); #else TCHAR szTitle[] = TEXT("Example 1"); #endif static SOCKET FdData = INVALID_SOCKET; static SOCKET sio_dopen(unsigned long ip,int port); static void Test(); extern void ConfigInit(); extern int ping(unsigned long ip); int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
Page 122
return (FALSE); while (GetMessage(&msg, 0, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); WSACleanup(); DestroyWindow(hwndMain); UnregisterClass(szTitle, hInstance); return(FALSE); /***************************************************************/ FUNCTION: InitApplication(HANDLE) PURPOSE: Initializes window data and registers window class /***************************************************************/ BOOL InitApplication(HANDLE hInstance) /* current instance WNDCLASS wc.style = 0; wc.lpfnWndProc = MainWndProc; wc.cbClsExtra = 0;...
Page 123
/***************************************************************/ FUNCTION: InitInstance(HANDLE, int) PURPOSE: Saves instance handle and creates main window /***************************************************************/ BOOL InitInstance( HANDLE hInstance, /* Current instance identifier. nCmdShow) /* Param for first ShowWindow() call. */ HWND hwnd; /* Save the instance handle in static variable, which will be used in /* many subsequence calls from this application to Windows.
Page 124
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); return (TRUE); /* Returns the value from PostQuitMessage */ static INT CxChar,CyChar; LONG APIENTRY MainWndProc( HWND hwnd, UINT message, WPARAM wParam, LONG lParam) hdc; TEXTMETRIC switch (message) { case WM_CREATE: hdc = GetDC(hwnd); GetTextMetrics(hdc,&tm); CxChar = tm.tmMaxCharWidth; CyChar = tm.tmHeight;...
Page 125
Test() cx,cy,i,j,len; hdc; char buf[256]; /* clear screen */ ScrollWindow(hwndMain,0,-300,NULL,NULL); UpdateWindow(hwndMain); cy = cx = 0; hdc = GetDC(hwndMain); * Check CN2500 is alive or not * We use ping() to check CN2500 is alive or not
#...
Page 126
ReleaseDC(hwndMain,hdc); return; wsprintf(buf,"Open port %d@%s... Ok.",Port,Ips); TextOut(hdc,0,cy,buf,strlen(buf)); cy += CyChar; * Send data to CN2500 serial port if (send(FdData, "12345", 5, 0) == 5) wsprintf(buf,"Send '12345' to remote device ... ok."); else wsprintf(buf,"Send '12345' to remote device ... fail!"); TextOut(hdc,0,cy,buf,strlen(buf));...
Page 127
5 bytes from remote device .."); TextOut(hdc,0,cy,buf,strlen(buf)); ReleaseDC(hwndMain,hdc); cy += CyChar; i = 0; * Receive data from CN2500 serial port for (;;) { len=recv(FdData, buf, sizeof(buf), 0); if (len > 0) { hdc = GetDC(hwndMain); for (j=0;j<len;j++) { TextOut(hdc,cx,cy,&buf[j],1);...
Page 128
/* 1. create socket for data port /* 2. connect to that data port Note: data port is used for read/write real data. input : ip --> CN2500 IP Address port--> CN2500 serial port number output: INVALID_SOCKET --> fail else --> ok...
Page 129
= AF_INET; des.sin_addr.s_addr = ip; des.sin_port = p; len = sizeof(struct sockaddr_in); * connect to CN2500 data port i = 0; for (;;) { j = connect(fd,(struct sockaddr *)&des, len); if (j == 0) break; * If already connected, just return ok.
Setting Up Multiplex Setting Up Multiplex Setting Up Multiplex Setting Up Multiplex A A A A ccess ccess ccess ccess
!"#$%
&
$ %
$'
"%$
&& "
()*')
!! "
# !
...
Page 131
Configuring port operation mode Port Menu [Mode] '
%"
+%
",(-,./' $%%
(
& 0&%"!"#$ &
,
" $
...
Setting Up Windows NT Setting Up Windows NT Setting Up Windows NT Setting Up Windows NT Real COM port Real COM port Real COM port Real COM port
!
"# #
"$
"%
"
&
" '("
$'(
'(
#
$
")
(
)
(
)& #
)
(
*
#
)
(
+
,
'(
)
(
*
" -"
'(
#
)
)
)
#
'(
...
Page 244
Appendix C Appendix C Appendix C Appendix C SNMP Agent with MIB II SNMP Agent with MIB II SNMP Agent with MIB II SNMP Agent with MIB II
!
"#$$%&'(
&'!
)
)
...
Page 247
Appendix D Appendix D Appendix D Appendix D Pin Assignment and Cable Wiring Pin Assignment and Cable Wiring Pin Assignment and Cable Wiring Pin Assignment and Cable Wiring
!"
# $" ! !"
% $"
...
100BaseTX Port Pin Assignment and Cable Wiring 100BaseTX Port Pin Assignment &' & &' & Connecting to a Hub - Straight Through Cable Wiring " &' & &' ( & Connecting to a PC - Crossed Over Cable Wiring " + &'...