未知设备的串行端口连接

发布于 2024-10-10 02:47:35 字数 1829 浏览 2 评论 0原文

我有投币机接受器组,我想使用串行端口连接这台机器。我的主要问题是,我确实尝试了几乎所有设置来连接该机器。电缆上的引脚号写为第 3 和第 7。所以我尝试了一下,

    private void Form1_Load(object sender, EventArgs e)
    {   
        // SerialPort paraPort defined at designer's generated code        
        paraport = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);


        //I wanna access to windows controls from the thread
        System.Windows.Forms.Form.CheckForIllegalCrossThreadCalls = false;
    }


    private void button2_Click(object sender, EventArgs e)
    {
        //paraPort is the name of serialport class
        paraPort.ReadBufferSize = 1024;
        paraPort.WriteBufferSize = 1024;
        paraPort.ReadTimeout = 1000;
        paraPort.WriteTimeout = 1000;
        paraPort.NewLine = "\n";

        //Because 7th pin is for RTS which means request 2 send
        paraPort.Handshake = Handshake.RequestToSend;


        //Data Terminal Ready Enable
        paraPort.DtrEnable = true;
        paraPort.RtsEnable = true;
        paraPort.Open();

        //Then Thread check the procedure inside of try - catch block

     try{
        // Thread money defined at designer's generated code
        money = new Thread(new ThreadStart(CheckTheMachineState));
        money.Start();
     }catch(Exception e){
        MessageBox.Show("thread cannot be created"+e.Message);
     }

     }


        private void CheckTheMachineState()
        {
            richTextBox1.AppendText("Thread is running\n");


            //I wanna get the value of IOCTL_SERIAL_WAIT_ON_MASK
            //But I still don't know how

        }
    }

机器运转良好。但是当我使用 paraPort.ReadBufferSize 属性时,当硬币接受 :S 时它给我 0。当我使用 paraPort.Read 方法时,它会抛出超时异常:\

那么我能为这个东西做什么呢?我正在使用 portmon 工具来捕获投币机信号。

当我投入硬币时,IOCTL_SERIAL_WAIT_ON_MASK 值更改为 SUCESS。我怎样才能捕捉到这个值?

I've coin machine acceptor set and I wanna connect this machine using serialport. My main problem is, I did try almost every setting to connect that machine. The pin numbers are written on the cable as 3th and 7th. So I try

    private void Form1_Load(object sender, EventArgs e)
    {   
        // SerialPort paraPort defined at designer's generated code        
        paraport = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);


        //I wanna access to windows controls from the thread
        System.Windows.Forms.Form.CheckForIllegalCrossThreadCalls = false;
    }


    private void button2_Click(object sender, EventArgs e)
    {
        //paraPort is the name of serialport class
        paraPort.ReadBufferSize = 1024;
        paraPort.WriteBufferSize = 1024;
        paraPort.ReadTimeout = 1000;
        paraPort.WriteTimeout = 1000;
        paraPort.NewLine = "\n";

        //Because 7th pin is for RTS which means request 2 send
        paraPort.Handshake = Handshake.RequestToSend;


        //Data Terminal Ready Enable
        paraPort.DtrEnable = true;
        paraPort.RtsEnable = true;
        paraPort.Open();

        //Then Thread check the procedure inside of try - catch block

     try{
        // Thread money defined at designer's generated code
        money = new Thread(new ThreadStart(CheckTheMachineState));
        money.Start();
     }catch(Exception e){
        MessageBox.Show("thread cannot be created"+e.Message);
     }

     }


        private void CheckTheMachineState()
        {
            richTextBox1.AppendText("Thread is running\n");


            //I wanna get the value of IOCTL_SERIAL_WAIT_ON_MASK
            //But I still don't know how

        }
    }

The machine is working well. But when I use paraPort.ReadBufferSize property, it gives me 0 when the coin accept :S. When I use the paraPort.Read method it throws an timeout exception :\

So What can I do for this stuff ? I'm using portmon tools to catch the coin machine signal.

IOCTL_SERIAL_WAIT_ON_MASK value is changed as SUCESS when I put the coin. How can I catch this value ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热风软妹 2024-10-17 02:47:35

经过几天的工作,我已经弄清楚如何使用VB6通过串行端口将硬币接收器/验证器机器连接到PC,这样每个插入插槽的硬币都会触发一个信号,该信号将被PC捕获。

After several days of work, I have figured out how to connect a coin acceptor/validator machine to a PC via serial port using VB6, such that every coin inserted in the slot will trigger a signal that will be caught by the PC.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文