Author Topic: Reading/Writing USB Device  (Read 7114 times)

Alycat

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Reading/Writing USB Device
« Reply #15 on: September 20, 2011, 07:25:41 am »
OK, thanks - testing progressing...

Alycat

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Reading/Writing USB Device
« Reply #16 on: September 20, 2011, 11:45:53 pm »
When using
nrUsbDriver1.Install()
does that install a 32 bit or 64 bit or does it auto detect and install the correct driver?

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Reading/Writing USB Device
« Reply #17 on: September 21, 2011, 06:24:10 pm »
Hello

Install auto detects platform and installs necessary driver.

But please note that if your are using WinUSB you need place in to project needed resource (TnrUsbDriver32bit and TnrUsbDriver64bit)
For nrUsb all drivers are included into resource by default.

Roman Novgorodov
DeepSoftware LLC
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

Alycat

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Reading/Writing USB Device
« Reply #18 on: September 26, 2011, 07:08:33 am »
As mentioned, I wrote a small test program, along the lines of the above, a button to setup and another button to start (by setting active to true). All works fine.
I am using your nr driver, not WinUSB.
I then included the same code in my main program, setup runs, but starting generates an error, that the driver is not installed.
I then copied the actual unit and form from the test program in, and included that form, still fails.
I then moved the creation and display of the test form to the very start of the boot process of my program, still failed.
Is there something obvious I am missing here? I reran my small test program and it still works fine.
 

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Reading/Writing USB Device
« Reply #19 on: September 26, 2011, 07:21:16 am »
Hello

Please create simple project that shows error and upload source here. We will check.

Roman Novgorodov
DeepSoftware LLC
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

Alycat

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Reading/Writing USB Device
« Reply #20 on: September 26, 2011, 07:26:06 am »
Eeerr, that's the point, the simple test program works fine, it is only when the same code is included in the main program that it fails.

Alycat

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Reading/Writing USB Device
« Reply #21 on: September 26, 2011, 07:30:43 am »
Where do I upload to?

Alycat

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Reading/Writing USB Device
« Reply #22 on: September 26, 2011, 07:33:52 am »
I have managed to reproduce the problem, with all my main units commented out, have emailed the dpr and dproj file, which now only uses madExcept, FastMM and a small test unit, Unit1 (pas and dfm sent as well).

Alycat

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Reading/Writing USB Device
« Reply #23 on: September 26, 2011, 07:45:28 am »
Looks like it is a problem between your component and FastMM... you take FastMM out and it seems to work.

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Reading/Writing USB Device
« Reply #24 on: September 26, 2011, 08:49:33 am »
Hello

nrComm Liv does not contain FastMM unit.
I received your email with attachment. We will check it.

Roman Novgorodov
DeepSoftware LLC
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

Alycat

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Reading/Writing USB Device
« Reply #25 on: September 27, 2011, 11:33:04 pm »
Back to my test program...
The following is called to setup the device:
var
dev:integer;
begin
   ListBox1.Items.Add('Setup starting...');
   ListBox1.Refresh;
   nrUSB1.Update;
   dev:=nrUSB1.DeviceIndexOf(...,...);
   ListBox1.Items.Add('Device found at index: '+inttostr(dev));
   nrUSB1.SetDeviceIndex(dev);
   ListBox1.Items.Add('Device index set: '+inttostr(nrUSB1.DeviceIndex));
   ListBox1.Items.Add('Setup finished.');
   ListBox1.Refresh;
the following to start the device:
    nrUSB1.Active := true;
    nrUSBPipePair1.Active := true;
 
This works ok.
If the setup is called again, nothing works, looks like the PipePair's receive data does not trigger.
I included setting of pipein and pipeout in the setup, it seems to read a bit of data, then stop.
 

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Reading/Writing USB Device
« Reply #26 on: September 28, 2011, 07:27:46 am »
Hello

Better if you will close all before refresh device list and change DeviceIndex:

Code: [Select]
...
begin
    nrUSBPipePair1.Active := false;    // <!!!!
    nrUSB1.Active := false;               // <!!!!
   ListBox1.Items.Add('Setup starting...');
   ListBox1.Refresh;
   nrUSB1.Update;
   ....

Roman Novgorodov
DeepSoftware LLC
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

Alycat

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Reading/Writing USB Device
« Reply #27 on: September 28, 2011, 07:36:34 am »
Thanks, will try that.

Alycat

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Reading/Writing USB Device
« Reply #28 on: September 28, 2011, 09:10:29 am »
Tried it, first time I ran setup for the second time and then start, about 4 records displayed (maybe already in the buffer), then stopped. Now, it is strange, not working correctly, looking...

Alycat

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Reading/Writing USB Device
« Reply #29 on: September 28, 2011, 10:45:51 pm »
Had to get the usb device rebooted...
Ran the earlier test program, all ok, provided setup not run twice.
Setting nrUSB and PipePair Active to false in setup causes problems, everything stops responding, setup runs ok, but start fails to produce any data???