Jump to content
OMRON Forums

Visual Studio 6.0 C++ setup for USB communication with Turbo PMAC


IslayRod
 Share

Recommended Posts

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Sina, I am able to successfully at performing the functions below: CoInitialize(NULL); testInterface = pmacDevice.CreateDispatch(_T("PcommServer.PmacDevice.1")); pmacDevice.SelectDevice(NULL,&dwDevice,&pbSuccess); pmacDevice.Open(dwDevice,&pbSuccess); pAvail = pmacDevice.GetDPRAvailable(dwDevice ); DPLenWords = pmacDevice.GetDPRSize(dwDevice); However when I try to do a GetResponseEx pmacDevice.GetResponseEx(dwDevice,Quest,bAddLF,pAns,&DPSuccess); I'm not sure how to interperate the results. DPSuccess = 0x80000007 which is good, but I don't unstand what is in the pAns (answer). Do you have any "Visual Studio 6.0" C++ examples that call pmacDevice.GetResponseEx(dwDevice,Quest,bAddLF,pAns,&DPSuccess); and dispaly the results? see code below. // TODO: Add Delta Tau extra initialization here long testInterface; long dwDevice; BOOL pbSuccess; CoInitialize(NULL); testInterface = pmacDevice.CreateDispatch(_T("PcommServer.PmacDevice.1")); if (!testInterface) AfxMessageBox("Can Not Connect PcommServer Interface "); pmacDevice.SelectDevice(NULL,&dwDevice,&pbSuccess); pmacDevice.Open(dwDevice,&pbSuccess); bool pAvail; pAvail = pmacDevice.GetDPRAvailable(dwDevice ); long DPLenWords, DPSuccess; VARIANT_BOOL bAddLF = true; DPLenWords = pmacDevice.GetDPRSize(dwDevice); char Question[2000]; LPCTSTR Quest ; BSTR pAns[5000] ; CString SAns; Quest = Question; sprintf(Question,"I8000"); pmacDevice.GetResponseEx(dwDevice,Quest,bAddLF,pAns,&DPSuccess); // TODO: End Add Delta Tau extra initialization here Thanks, Islay
Link to comment
Share on other sites

Good Day Islay, You could also look at the examples in C# sent and see examples of details when using the functions. The syntax is different but calls and responses to the Pcomm functions are the same. Also look at the PcommServer manual Page 12 under "Using the Reference to PcommServer in VB.NET" it shows GetResponseEx being used with the return response as a string... Below you ask: I don't unstand what is in the pAns (answer). pAns is a String with PMAC response - it can be string data or empty depending on the question or command sent, in your example I think you are sending a empty command so getting a empty pAns. Then you show this example code: Quest = Question; sprintf(Question,"I8000"); pmacDevice.GetResponseEx(dwDevice,Quest,bAddLF,pAns,&DPSuccess); The above example I think is bad, I don't see all the code so am not sure what the value of "Quest" actually is ? However it appears you want it to be "I8000", but the above code sets "Question" to "I8000" not "Quest" ? So perhaps you are passing the command "Quest" which is empty to pmac so in return the pAns is also empty. If in above example you did send "I8000" as the question the pAns would be a String return with the current value of I8000 in the PMAC. Some commands sent to PMAC will result in a empty return string. For example if you send the "#1j/" command the return would be empty string unless there is a error then it might return "ERR018" or something similar.
Link to comment
Share on other sites

Here is an example showing one way in VS6 C++ to make the GetResponseEx call and get the response. CString command; CString response; long status; BSTR MyBstr = SysAllocString(L"1"); int progRunMvar; progRunMvar= GetPrivateProfileInt( "Settings", "progRunMvar", 10, BaseDir ); char charBuf[10]; itoa(progRunMvar,charBuf,10); command = "M"; command += charBuf; //command = "M5180"; //tay101 CString str; do { //here we will loop as long as the Mvar we look at is still 1 //-this tells us that the CS is still running the program //-we wait here till the program is done Sleep(10); pmacDevice->GetResponseEx (dwDevice,command,0,&MyBstr,&status); Sleep(10); response = MyBstr; response = response.Left (response.GetLength() -1); //strip null char from end } while (response != "0");
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...