Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7534785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:07:07+00:00 2026-05-30T06:07:07+00:00

Basically, I am trying to control a USB device (a linear actuator control board)

  • 0

Basically, I am trying to control a USB device (a linear actuator control board) using the supplied DLL (mpusbapi.dll) and header file (mpusbapi.h). However, I can’t for the life of me figure out which parameters I need to pass into MPUSBWrite().

In particular, the 2nd, 3rd and 4thparameters of MPUSBWrite(). The first parameter is clearly the handle that is returned by MPUSBOpen() and the last parameter is a timeout in ms.

I have a hunch it has something to do with page 6 of LAC advance config.

Any help is GREATLY appreciated. Thanks!

mpusbapi.h file

#ifndef _MPUSBAPI_H_
#define _MPUSBAPI_H_

#define MPUSB_FAIL                  0
#define MPUSB_SUCCESS               1

#define MP_WRITE                    0
#define MP_READ                     1

// MAX_NUM_MPUSB_DEV is an abstract limitation.
// It is very unlikely that a computer system will have more
// then 127 USB devices attached to it. (single or multiple USB hosts)
#define MAX_NUM_MPUSB_DEV           127

DWORD (*MPUSBGetDLLVersion)(void);

DWORD (*MPUSBGetDeviceCount)(PCHAR pVID_PID);

HANDLE (*MPUSBOpen)(DWORD instance,         // Input
             PCHAR pVID_PID,            // Input
             PCHAR pEP,                 // Input
             DWORD dwDir,               // Input
             DWORD dwReserved);         // Input <Future Use>

DWORD (*MPUSBRead)(HANDLE handle,           // Input
            PVOID pData,                // Output
            DWORD dwLen,                // Input
            PDWORD pLength,             // Output
            DWORD dwMilliseconds);      // Input

DWORD (*MPUSBWrite)(HANDLE handle,          // Input
             PVOID pData,               // Input
             DWORD dwLen,               // Input
             PDWORD pLength,            // Output
             DWORD dwMilliseconds);     // Input

DWORD (*MPUSBReadInt)(HANDLE handle,        // Input
               PVOID pData,             // Output
               DWORD dwLen,             // Input
               PDWORD pLength,          // Output
               DWORD dwMilliseconds);   // Input

BOOL (*MPUSBClose)(HANDLE handle);

#endif

LACTesting.cpp file

#include <windows.h>     // This is a windows header file. The functions I mentioned above are declared here
#include "mpusbapi.h"    // This is the header file supplied. It declares the function prototypes that are defined in the DLL
#include <iostream>
#include "ioctls.h"

using namespace std;

int main(int argc, char* argv)
{
// Try to load the library
HMODULE mpbusDLL = NULL;
mpbusDLL = LoadLibrary(L"mpusbapi.dll");

if (mpbusDLL != NULL) {
    // If the library could be loaded, then load the functions using GetProcAddress()

    // Load the function 'MPUSBOpen' from the DLL
    MPUSBOpen = (HANDLE(*)(DWORD, PCHAR, PCHAR, DWORD, DWORD)) GetProcAddress(mpbusDLL, "_MPUSBOpen");
    MPUSBOpen=(HANDLE(*)(DWORD,PCHAR,PCHAR,DWORD,DWORD))GetProcAddress(mpbusDLL,"_MPUSBOpen");
    MPUSBGetDLLVersion=(DWORD(*)(void))GetProcAddress(mpbusDLL,"_MPUSBGetDLLVersion");
    MPUSBGetDeviceCount=(DWORD(*)(PCHAR))GetProcAddress(mpbusDLL,"_MPUSBGetDeviceCount");
    MPUSBWrite=(DWORD(*)(HANDLE,PVOID,DWORD,PDWORD,DWORD))GetProcAddress(mpbusDLL,"_MPUSBWrite");
    MPUSBRead=(DWORD(*)(HANDLE,PVOID,DWORD,PDWORD,DWORD))GetProcAddress(mpbusDLL,"_MPUSBRead");
    MPUSBReadInt=(DWORD(*)(HANDLE,PVOID,DWORD,PDWORD,DWORD))GetProcAddress(mpbusDLL,"_MPUSBReadInt");
    MPUSBClose=(BOOL(*)(HANDLE))GetProcAddress(mpbusDLL,"_MPUSBClose");
}
//If the DLL didn't load, let me know!
else cout<<"DLL didn't load"<<endl;

//Declarations
HANDLE LACHandle;
PCHAR pipeName=MCHPUSB_PIPE_NAME;// intializes pipeName to "\\MCHP_EP"
PCHAR VidPid="vid_04d8&pid_fc5f";

LACHandle=MPUSBOpen(0,VidPid,pipeName,1,0);//open device connection
                //Not sure if I pass in the correct arguements for MBUSBOpen. VidPid and pipeName are correct.

cout<<"Device ID "<<VidPid<<"is open with "<<MPUSBGetDeviceCount(VidPid)<<" device(s)."<<endl;
//sMPUSBWrite(LACHandle,,3,,1000); <- this is where I am having issues.
                                    //I can't figure out how to use MPUSBWrite
MPUSBClose(LACHandle);// closes device connection

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:07:08+00:00Added an answer on May 30, 2026 at 6:07 am

    I think you should take a look at

    Win32 Data Types

    then work on Windows System Programming samples, then you will clearly understand the logic.

    To your question, as i see the code i can guess

             // yourData which want to write
             PVOID pData
             // sizeof(yourData)  google "sizeof"
             DWORD dwLen
             /* I have no idea about this, but its output you can see it 
             after running function */               
             PDWORD pLength           
    

    Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I'm trying to change the Canvas.Left property of an Ellipse Silverlight control in
I am trying to make a range control which is basically a slider control
I'm trying to create a GUI (WPF) Library where each (custom) control basically wraps
I'm trying to control an instance of the JW FLV player player using jquery.
Basically I am inserting an image using the listviews inserting event, trying to resize
I'm using a repeater control and I'm trying to pass a parameter as such:
I Have Been Trying for days on how to do this. Basically You Control
I've got an ASP user control which is basically using jquery UI datepicker just
I am trying to create a control which is basically showing a list of
I'm trying to create a custom control for a silverlight app that will basically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.