问下大家.net在做串口通信方面怎么样?
比如说POS机与PC机之间的通信
我用.NET做PC端后台管理与POS机之间通信 好实现吗? 
小弟对串口通信不懂啊 这次没办法要接触

解决方案 »

  1.   

    .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.   
      

  2.   

    好做啊,看你pos机上的系统是什么的,之后根据pos机上的串口通信协议直接向串口下发数据就ok了,需要注意的是串口数据的丢弃,以免串口阻塞
      

  3.   

    http://topic.csdn.net/u/20080623/08/4bbd2475-45f1-42e3-a613-16b094759ade.html
      

  4.   

    直接用SerialPort类来做,非常简单了。首先从工具箱中加入到窗体中,然后再通过属性设置好相关属性。然后添加事件,主要有dataRecieved事件,即在串口数据到达的时候触发该事件。常用到的方法有SerialPort.ReadExist()//用于获取串口中数据。
    SerialPort.Write() //用于向串口写入数据,即发送数据到串口。
      

  5.   

    用SerialPort做过串口通讯,但是不知道性能怎么样。
      

  6.   

    对,用SerialPort,但要注意添加线程
      

  7.   

    .net 做串口通讯 很简单 实现起来很方便 
      

  8.   

    哥哥们 为什么.NET做什么都简单啊?vc 一样的效果复杂多了
    是不是效率上有不同?