.Net串口通信问题 快来啊~~

yale28 2009-04-01 06:34:21
问下大家.net在做串口通信方面怎么样?
比如说POS机与PC机之间的通信
我用.NET做PC端后台管理与POS机之间通信 好实现吗?
小弟对串口通信不懂啊 这次没办法要接触
...全文
328 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
睡神在睡觉 2009-04-11
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 yale28 的回复:]
哥哥们 为什么.NET做什么都简单啊?vc 一样的效果复杂多了
是不是效率上有不同?
[/Quote]

做串口通信c++的效率肯定比c#要高,至于为什么做的多了就明白了
beizu 2009-04-11
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 sleep0110 的回复:]
好做啊,看你pos机上的系统是什么的,之后根据pos机上的串口通信协议直接向串口下发数据就ok了,需要注意的是串口数据的丢弃,以免串口阻塞
[/Quote]
网上很多例子
gisyellow 2009-04-02
  • 打赏
  • 举报
回复
只知道要用SerialPort来做,具体没用过,帮顶。。
zhamx 2009-04-02
  • 打赏
  • 举报
回复
.net 做串口通讯 很简单 实现起来很方便
zhi11ming 2009-04-02
  • 打赏
  • 举报
回复
对,用SerialPort,但要注意添加线程
018 2009-04-02
  • 打赏
  • 举报
回复
用SerialPort做过串口通讯,但是不知道性能怎么样。
yale28 2009-04-02
  • 打赏
  • 举报
回复
哥哥们 为什么.NET做什么都简单啊?vc 一样的效果复杂多了
是不是效率上有不同?
josephSC 2009-04-02
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 gisyellow 的回复:]
只知道要用SerialPort来做,具体没用过,帮顶。。
[/Quote].
哈哈潜伏哥 2009-04-01
  • 打赏
  • 举报
回复
直接用SerialPort类来做,非常简单了。

首先从工具箱中加入到窗体中,然后再通过属性设置好相关属性。然后添加事件,主要有dataRecieved事件,即在串口数据到达的时候触发该事件。

常用到的方法有SerialPort.ReadExist()//用于获取串口中数据。
SerialPort.Write() //用于向串口写入数据,即发送数据到串口。
patrickpan 2009-04-01
  • 打赏
  • 举报
回复
微软提供一个组件,和串口通讯的,LZ找找。
zzxap 2009-04-01
  • 打赏
  • 举报
回复
http://topic.csdn.net/u/20080623/08/4bbd2475-45f1-42e3-a613-16b094759ade.html
jlj84237485 2009-04-01
  • 打赏
  • 举报
回复
帮顶一下
highfly2008 2009-04-01
  • 打赏
  • 举报
回复
SerialPort
doubleu2005 2009-04-01
  • 打赏
  • 举报
回复
比较好做
热学沸腾56 2009-04-01
  • 打赏
  • 举报
回复
不懂的帮顶!
睡神在睡觉 2009-04-01
  • 打赏
  • 举报
回复
好做啊,看你pos机上的系统是什么的,之后根据pos机上的串口通信协议直接向串口下发数据就ok了,需要注意的是串口数据的丢弃,以免串口阻塞
oyljerry 2009-04-01
  • 打赏
  • 举报
回复
.NET is a high-level framework
and doesn't support direct port access.


My Serial Port FAQ:

.NET 1.0 has no support for legacy ports (COM/LPT).

There are plans to add support for serial ports in a future version:
http://groups.google.com/groups?&selm=O%23vQLn9bCHA.392%40tkmsftngp09
"this sample is very similar to what we will be adding" :
http://www.gotdotnet.com/userarea/filedetails.aspx?FileName=SerialPort.zip
(note, project built with beta VS.NET, read gotdotnet comments)

With 1.0 you have to use PInvoke or Interop :

First understand the Win32 API as described here (C++):
http://msdn.microsoft.com/library/en-us/dnfiles/html/msdn_serial.asp

New MSDN article for .NET (mostly C#):
http://msdn.microsoft.com/msdnmag/issues/02/10/NETSerialComm/

PInvoke samples for C#:
http://www.gotdotnet.com/userarea/filedetails.aspx?FileName=SerialPort.zip
http://msdn.microsoft.com/msdnmag/issues/02/10/NETSerialComm/

or for VB.NET:
http://msdn.microsoft.com/library/en-us/dnvssamp/html/vbcs_usingthecomportinvbnet.asp


My Parallel Port FAQ:

If you have to send raw data to a printer:

HOW TO: Send Raw Data to a Printer by Using Visual C# .NET :
http://support.microsoft.com/?kbid=322091


If you want to control the port pins:
You have to install some kind of hardware drivers!
(Warning: will impact system security/reliability)

for .NET : TSIO (generic IO)
www.thoroughsoft.com
http://65.184.102.81/thoroughsoft/products/Products_TSIO/Products_TSIO.aspx

commercial, specific for printer ports, e.g.:
http://www.zealsoftstudio.com/ntport/download.html
http://www.ntport.com/

C++/Win32
http://www.entechtaiwan.com/tviclpt.htm
http://www.internals.com/

For more information about ports, check this sites:
http://www.lvr.com/parport.htm
http://www.beyondlogic.org


My USB Port FAQ:

USB is a hardware bus and as such not directly exposed
to user-mode (Win32) applications (or even .NET).
Only Windows device-drivers do control the USB.
=> get a driver from manufacturer.

So if you connect a printer with USB, use the Win32/.NET printer-API.
Or if you connect a modem with USB, use the Win32 serial-API.
Or if you connect an imaging device (camera/scanner), use TWAIN/WIA.

If you want to design your own external, USB compliant hardware,
you have to understand the USB bus protocol
and implement a controller chip.
Then on Windows side, you have to write your own
device driver with the Windows DDK.
Sure there are OEM kits making all this easier.

Please visit sites like:
http://www.usb.org/
http://www.microsoft.com/hwdev/bus/USB/
http://www.lvr.com/usb.htm
http://www.beyondlogic.org
and learn the technology.

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧