Electronic Engineer Discuss

View: 9131|Reply: 4
Print Prev. thread Next thread

C# project for Hantek6074BC

[Copy link]

3

Threads

6

Posts

6

Credits

新手上路

Rank: 1

Credits
6
1#
Post time 2021-8-26 21:30:23 | Show all posts
I have the same problem.
Most of the HTHardDll.dll functions works well, but I have troubles with dsoHTGetData: it always returns 0.
Any ideas ?

3

Threads

6

Posts

6

Credits

新手上路

Rank: 1

Credits
6
2#
Post time 2021-8-30 21:41:14 | Show all posts
Thanks for your answer e_admin. Now dsoHTGetData returns 1, but I still have troubles to get all the data. According to vcdemo I created 4 arrays of ushort, and sent the pointers to dsoHTGetData. I get back 190 values for CH1 and CH2, and nothing for CH3 and CH4. I expect 8192 values for the 4 arrays so there is a lot missing. I dont know whats going wrong. Here is how I call the function :

  1.             ushort[] readBufferCH1 = new ushort[8192];
  2.             ushort[] readBufferCH2 = new ushort[8192];
  3.             ushort[] readBufferCH3 = new ushort[8192];
  4.             ushort[] readBufferCH4 = new ushort[8192];

  5.             int result = GetData(Hantek_DeviceIndex, readBufferCH1, readBufferCH2, readBufferCH3, readBufferCH4, stControl);

  6.             for (int i = 0; i < 8192; i++)
  7.             {
  8.                 CHRead_Buffer[i, 0] = readBufferCH1[i];
  9.                 CHRead_Buffer[i, 1] = readBufferCH2[i];
  10.                 CHRead_Buffer[i, 2] = readBufferCH3[i];
  11.                 CHRead_Buffer[i, 3] = readBufferCH4[i];
  12.             }
Copy the Code


And here is the call to the dll :

  1.         [DllImport("HTHardDll.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
  2.         private static unsafe extern int dsoHTGetData(int nDeviceIndex, ushort* CH1Data, ushort* CH2Data, ushort* CH3Data, ushort* CH4Data, ref ControlData pSTControl);

  3.         public int GetData(int nDeviceIndex, ushort[] CH1Data, ushort[] CH2Data, ushort[] CH3Data, ushort[] CH4Data, ControlData pSTControl)
  4.         {
  5.             unsafe
  6.             {
  7.                 fixed (ushort* pCH1Data = CH1Data)
  8.                 fixed (ushort* pCH2Data = CH2Data)
  9.                 fixed (ushort* pCH3Data = CH3Data)
  10.                 fixed (ushort* pCH4Data = CH4Data)
  11.                 {
  12.                     return dsoHTGetData(nDeviceIndex, pCH1Data, pCH2Data, pCH3Data, pCH4Data, ref pSTControl);
  13.                 }
  14.             }
  15.         }
Copy the Code


And last thing that may cause the problem : the ControlData. Here is how mine looks like :

  1.                 nCHSet = 15,
  2.                 nTimeDiv = 16,
  3.                 nTriggerSource = 0,
  4.                 nHTriggerPos = 50,
  5.                 nVTriggerPos = 192,
  6.                 nTriggerSlope = 0,
  7.                 nBufferLen = 8192,
  8.                 nReadDataLen = 8192,
  9.                 nAlreadyReadLen = 0,
  10.                 nALT = 0
Copy the Code


Thanks a lot in advance for the help
You have to log in before you can reply Login | Register

Points Rules

Dark room|Mobile|Archiver|Electronic Engineer Discuss

2024-5-3 16:39 GMT+8 , Processed in 0.194993 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

Quick Reply To Top Return to the list