使用c#访问Sony P2 VTR硬件设备

Access Sony P2 VTR hardware device using c#

Sony VTR(9-pin) 硬件想用 c# 控制 application.I 不知道如何 communicate/send 命令 com port.I 想执行播放、暂停等命令获取视频的当前时间码,建议我用 c# 编写示例代码。

  // Create the serial port with basic settings
 //change parity bit,COM name,bit rate,baud rate according to requirements.
  private SerialPort port = new SerialPort("COM1",38400, Parity.Odd, 8, StopBits.One);

  public byte[] play()
    {
        var checkCommand = new byte[6];
        checkCommand[0] = 0x20;
        checkCommand[1] = 0x01;
        checkCommand[2] = 0x21;
        checkCommand[3] = 0x00;
        checkCommand[4] = 0x00;
        checkCommand[5] = 0x00;

        try
        {
            if (!port.IsOpen)
            {                  
                port.Open();
            }              
            port.Write(checkCommand, 0, checkCommand.Length);
              return checkCommand;
        }
        catch (ArgumentException ex)
        {
            throw new InvalidOperationException("Locker cell can not be opened.", ex);
        }
    }