UsbLibDotNetTest Example does not work for me

时间:2017-12-18 07:32:29

标签: c# usb libusbdotnet

IM trying to write and read from\to USB... I got Win32Error on

<?php
$stmt1 = oci_parse($conn, $query1);
oci_execute($stmt1);
$mssqlaray = array();
$index = 0;
while (($row1 = oci_fetch_array($stmt1, OCI_BOTH))) 
{
  $mssqlaray[$index] = $row1;
    $index++;
}

for($j = 0; $j < oci_num_rows($stmt1); $j+=2)
{
  echo '
  <div class="col-sm-6">
        <div class="checkbox checkbox-primary">
            <input id="checkbox1'.$mssqlaray[$j][0].'" type="checkbox">
            <label for="checkbox1'.$mssqlaray[$j][0].'">'.$mssqlaray[$j][1].'   </label>
        </div>
    </div>';
}
for($j = 1; $j < oci_num_rows($stmt1); $j+=2)
{
    echo '
  <div class="col-sm-6">
        <div class="checkbox checkbox-primary">
            <input id="checkbox1'.$mssqlaray[$j][0].'"type="checkbox">
            <label for="checkbox1'.$mssqlaray[$j][0].'">'.$mssqlaray[$j][1].'</label>
        </div>
    </div>';
}

and I got 0 in bytesRead than it throw Exception("No more bytes!");

ec = reader.Read(readBuffer, 10000, out bytesRead);

I write the next string this string work very well when I tried to use port rs232 using SerialPort Object. But it does not work for USB port...

if (bytesRead == 0) throw new Exceptio`enter code here`n("No more bytes!");

Maybe is exist Any object in C# line SerialPort for USB port? I did not find anything about it and I don't know what else can I do...

string cmdLine = @"@01WD300000295B*"+(char)13;

1 个答案:

答案 0 :(得分:0)

我发现并非所有USB转串口转换似乎都能正常工作。我使用的是Ugreen USB to Serial。这在Windows 7和Windows 10上对我有用。 http://www.ugreen.com.cn/product-681-en.html 另一个有效的转换器是Sabrent。但是,这仅适用于Windows XP和Windows 7。 问候, 加里