/************************************************************************
TimeOut.c
-- Main module for read & write timeout setting example program.
Description:
1.Select "setting..." menu item to set com port option.
2.Select "Open" menu item to open com port.
After selected "Open" from menu, you can select
"Timeout Demo" to test timeout status.
Polling Write:
sio_write() will return immediately. The data will be
copied to driver,but do not really wrtie to com port. This
operation will maybe let sio_write() return 0, means that
not enough buffer to write. Be careful this polling operation
will 'eat' a large amount of system resource, including
memory, processor time.
Block Write:
sio_write() will block until the all data has be write to
com port (But maybe some data is still in com port output
buffer when sio_write() return). You can check the sio_write()
elapsed time. This operation is suitable to using another
thread to write data. Then you can call sio_AbortWrite()
to abort write operation in main thread when you want to
stop writing.
Block Write (Timeout):
This operation is the same as "Block Write". The difference
is that, sio_write() will block until the tiemout is arrived
or the all data has be write to com port. You can decrease
the timeout value to check the difference.
Polling Read:
sio_read() will return immediately. sio_read() just checks
input buffer, gets all buffer data (maybe less than or equal
to that sio_read() want to read), then returns. If no data in
buffer, sio_read() return 0. Be careful this polling operation
will 'eat' a large amount of system resource, including memory,
processor time.
Block Read:
sio_read() will block until the input buffer data length is
equal to that sio_read() want to read. This operation is
suitable to using another thread to read data. Then you can
call sio_AbortRead() to abort read operation in main thread
when you want to stop reading.
Block Read (Total Timeout):
This operation is the saem as "Block Read". The difference
is that, sio_read() will block until timeout is arrived or
the input buffer data length is equal to that sio_read()
want to read.You can decrease the timeout value to check
the difference.
In this example, you can connect to terminal. Then you can
try 2 cases from terminal:
send 10240 bytes,
or wait the timeout is arrived.
Check the sio_read() elapsed time.
Block Read (Interval Timeout):
sio_read() will wait the first byte arrived, then begin
interval timeout checking.sio_read will block until the
interval timeout is arrived or the input buffer data length
is equal to that sio_read() want to read.
In this example, you can connect to terminal. Then you can
try 2 cases from terminal:
send 1 or 2 byte,
send 10240 bytes,
Check the sio_read() elapsed time.
Block Read ( Total+Interval Timeout ):
sio_read() will block until the timeout is arrived or the
input buffer data length is equdal to that sio_read() want
to read.
In this example, you can connect to terminal. Then you can
try 3 cases from terminal :
send 1 or 2 byte,
send 10240 bytes,
send > 10240 bytes
Check the sio_read() elapsed time.
3.Select "Close" menu item to close com port.
This program demo:
How to set write timeout(sio_SetWriteTimeouts());
How to set read timeout(sio_SetReadTimeouts());
How to abort write process(sio_AbortWrite());
How to abort read process(sio_AbortRead());
Use function:
sio_open, sio_close, sio_ioctl,
sio_flowctrl, sio_DTR, sio_RTS,
sio_read, sio_write,
sio_SetWriteTimesout, sio_SetReadTimeouts,
sio_AbortWrite, sio_AbortRead;
History: Date Author Comment
3/1/98 Casper Wrote it.
*************************************************************************/
#include <windows.h>
#include <windowsx.h>
#include "PComm.h"
#include "mxtool.h"
#include "resource.h"
#include "comm.h"
#define BUFLEN (10*1024)
HINSTANCE GhInst;
COMMDATA GCommData;
BOOL GbOpen;
HANDLE GhExit;
DWORD GDifTime;
DWORD GCount;
DWORD GCallCount;
char GszAppName[] = "TimeOut Setting Demo";
static char _GBuf[BUFLEN];
static HANDLE hWriteThread;
static HANDLE hReadThread;
static HWND GhWnd;
LRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK PortDlgProc(HWND hDlg,UINT iMsg,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK AboutDlgProc(HWND hDlg,UINT iMsg,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK WStatDlgProc(HWND hDlg,UINT iMsg,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK RStatDlgProc(HWND hDlg,UINT iMsg,WPARAM wParam,LPARAM lParam);
static void SwitchMenu(HWND hwnd);
static BOOL OpenPort(void);
static BOOL ClosePort(void);
static BOOL PortSet(void);
static void ShowStatus(void);
UINT WriteProc( LPVOID pParam );
UINT ReadProc( LPVOID pParam );
void DemoWriteTimeout(int port,UINT testitem);
void DemoReadTimeout(int port,UINT testitem);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
PSTR szCmdLine,int iCmdShow)
{
WNDCLASSEX wndclass;
HWND hwnd;
MSG msg;
GhInst = hInstance;
wndclass.cbSize = sizeof(WNDCLASSEX);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndclass.lpszMenuName = MAKEINTRESOURCE(IDM_TIMEOUT);
wndclass.lpszClassName = GszAppName;
wndclass.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
RegisterClassEx(&wndclass);
hwnd = CreateWindow(GszAppName,
GszAppName,
WS_OVERLAPPEDWINDOW ,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL,NULL,
hInstance,
NULL);
GhWnd = hwnd;
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)
{
switch(iMsg){
case WM_COMMAND:
switch(LOWORD(wParam)){
case IDM_PORT_OPEN:
OpenPort();
return 0;
case IDM_PORT_CLOSE:
ClosePort();
return 0;
case IDM_PORT_SETTING:{
COMMDATA bakdata = GCommData;
if(DialogBox(GhInst,MAKEINTRESOURCE(IDD_OPEN),hwnd,PortDlgProc)==IDCANCEL)
return 0;
if(GbOpen)
if (!PortSet())
GCommData = bakdata;
return 0;
}
case IDM_WRITE_POLL:
case IDM_WRITE_BLOCK:
case IDM_WRITE_TIMEOUT:
DemoWriteTimeout(GCommData.Port,LOWORD(wParam));
return 0;
case IDM_READ_POLL:
case IDM_READ_BLOCK:
case IDM_READ_BLOCK_T:
case IDM_READ_BLOCK_I:
case IDM_READ_BLOCK_TI:
DemoReadTimeout(GCommData.Port,LOWORD(wParam));
return 0;
case IDM_HELP_ABOUT:
DialogBox(GhInst,MAKEINTRES
没有合适的资源?快使用搜索试试~ 我知道了~
PComm_Pro.rar_PCOMM PUDN_Pcomm Pro_delphi 串口_pcomm_pcomm builder
共117个文件
pas:21个
frm:13个
dfm:13个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 65 浏览量
2022-09-23
22:45:21
上传
评论
收藏 719KB RAR 举报
温馨提示
这是一个串口通讯控件,大家可以使用这个三方控件来进行串口间的通讯,希望大家可以使得开心
资源推荐
资源详情
资源评论
收起资源包目录
PComm_Pro.rar_PCOMM PUDN_Pcomm Pro_delphi 串口_pcomm_pcomm builder (117个子文件)
ANSI 1KB
PCOMM.BAS 9KB
PCOMM.BAS 9KB
FTPROC.BAS 8KB
GLOBAL.BAS 4KB
MXTOOL.BAS 2KB
IRQFUNC.BAS 2KB
TIMEPROC.BAS 2KB
FTRANS.BC 2KB
PORTSTAT.BC 1KB
TIMEOUT.BC 1KB
IRQDEMO.BC 1KB
SIMPLE.BC 1KB
TIMEOUT.C 16KB
FTRANS.C 15KB
IRQDEMO.C 14KB
PORTSTAT.C 13KB
SIMPLE.C 12KB
FTPROC.C 6KB
STATDLG.C 6KB
COMM.C 6KB
FSTATUS.C 3KB
STAT.C 2KB
FTSET.C 2KB
MXTOOL.C 2KB
ABOUT.C 1KB
PCOMM.CNT 665B
STATDLG.DFM 3KB
CONFIG.DFM 2KB
TMOUTM.DFM 2KB
FSTAT.DFM 1KB
IRQDEMOM.DFM 1006B
PSTATM.DFM 984B
FTRANSM.DFM 981B
SIMPLEM.DFM 960B
WSTAT.DFM 891B
RSTAT.DFM 884B
DIRDLG.DFM 842B
FSET.DFM 825B
ABOUT.DFM 530B
PCOMM.DLL 57KB
FTRANS.DPR 740B
TIMEOUT.DPR 662B
PORTSTAT.DPR 590B
SIMPLE.DPR 502B
IRQDEMO.DPR 495B
MXSCOPE.EXE 416KB
MXTERM.EXE 409KB
BURNIN.EXE 342KB
TIMEOUT.FRM 14KB
STATDLG.FRM 11KB
IRQDEMO.FRM 10KB
SIMPLE.FRM 9KB
FTRANS.FRM 9KB
PORTSTAT.FRM 8KB
CONFIG.FRM 7KB
FSET.FRM 5KB
FTSTAT.FRM 4KB
RSTAT.FRM 3KB
WSTAT.FRM 3KB
DIR.FRM 3KB
ABOUT.FRM 1KB
CONFIG.FRX 299B
PCOMM.H 7KB
RESOURCE.H 6KB
FTRANS.H 651B
COMM.H 527B
MXTOOL.H 131B
PCOMM.HLP 191KB
GUIDES.HLP 122KB
MXSCOPE.HLP 72KB
BURNIN.HLP 48KB
PORTING.HLP 43KB
MXTERM.HLP 22KB
PCOMM.LIB 33KB
PCOMMB.LIB 6KB
2ccc.com.nfo 946B
2ccc.com.nfo 946B
TMOUTM.PAS 11KB
PCOMM.PAS 9KB
PCOMM.PAS 9KB
IRQDEMOM.PAS 8KB
FTRANSM.PAS 7KB
PSTATM.PAS 6KB
SIMPLEM.PAS 6KB
FTPROC.PAS 5KB
STATDLG.PAS 5KB
CONFIG.PAS 3KB
EXGLOBAL.PAS 3KB
TOTHREAD.PAS 2KB
IRQPROC.PAS 2KB
MXTOOL.PAS 2KB
FSTAT.PAS 2KB
READTHD.PAS 2KB
DIRDLG.PAS 1KB
FSET.PAS 1KB
ABOUT.PAS 1014B
RSTAT.PAS 973B
WSTAT.PAS 972B
FTRANS.RC 5KB
共 117 条
- 1
- 2
资源评论
寒泊
- 粉丝: 75
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功