Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun May 28, 2017 11:39 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Any success with MBS WinHID plugin?
PostPosted: Tue Jun 02, 2009 7:39 pm 
Offline

Joined: Wed Jul 09, 2008 10:46 pm
Posts: 193
Location: Minneapolis
Has anyone had success with the "sendmessage" functions within the MBS WinHID plugin?

I've been able to connect and read messages from a device but cannot successfully send a message. I think my message structure is correct (99% sure but have questions about the HID report IDs) but the function always return 0 bytes sent with one of the following lasterror codes:
Quote:
1784 - System error code 1784 means "The supplied user buffer is not valid for the requested operation." This error code may also display as "ERROR_INVALID_USER_BUFFER" or as the value 0x6F8.

87 - System error code 87 means "The parameter is incorrect." This error code may also display as "ERROR_INVALID_PARAMETER" or as the value 0x57.
If you have got it to work I would love to ask you a few questions and/or see some sample code.

Thanks,
David

P.S. I did post on the MBS forum a few days ago but traffic over there seems kind of light - no one has even viewed the message yet...

_________________
http://www.miscjunk.org


Top
 Profile  
 
 Post subject: Re: Any success with MBS WinHID plugin?
PostPosted: Wed Feb 10, 2010 4:26 pm 
Offline

Joined: Fri Jan 08, 2010 11:46 am
Posts: 6
Location: Dallas, TX
I'm trying to do a 'simple' read of a card with a USB HID Card Reader. My platform is Windows XP Pro. I've tried using the PollString + InstallListener, but I must be doing something wrong since the PollString is returning zilch. I've recently tried using ReadMessage instead and am getting 1784 error on the ReadMessage.
You said you were able to get the Read to work. Is this in Windows? If so can you PLEASE send me a sample of the code? I must not be understanding the doc with the plugin. I would have thought after calling InstallListener that a thread would appear in the Globals but I see nothing. If I'm supposed to do something with the ThreadHandle that is assigned, I'm not sure what that is that I'm supposed to do. Somehow, the listener and poll aren't interacting it seems. Any help is much appreciated.


Top
 Profile  
 
 Post subject: Re: Any success with MBS WinHID plugin?
PostPosted: Thu Feb 11, 2010 7:32 pm 
Offline

Joined: Wed Jul 09, 2008 10:46 pm
Posts: 193
Location: Minneapolis
I'll try to help but a couple of points:

1) I moved to using a HID.dll and all the MBS code was commented out - and I don't remember what state the MBS stuff was in when I switched
2) I don't have the device any longer (a Delorme GPS) so I cannot do anything but give the code fragments I had commented out:

In my open event:
if not registerMBSPlugin(...) then
MsgBox "Problem with MBS Plugin"
end if
app.hid = new WinHIDMBS

In my connect button action:
if app.hid.FindFirstDevice then
do
dev = app.hid.product + " (" + app.hid.serialnumber + ")"

if app.hid.VendorID = 4451 then
call app.hid.Connect

if app.hid.Lasterror <> 0 then
StatusMsg("ERROR - could not establish connection.")
else
StatusMsg("Connected to " + dev)

Listen.Run
exit
end
else
StatusMsg("ERROR - could not find unit.")
end
loop until not app.hid.FindNextDevice
end if

In the Run event of the Listen timer:
seg = app.hid.ReadMessage(1000)

for i as integer =1 to len(seg)
bs = hex(ascb(mid(seg, i, 1)))
if len(bs) =1 then
bs = "0" + bs
end
buf = buf + bs

pos = InStr(buf, "DBFE")
if pos > 0 then
msg = left(buf, pos-1)
//LogFld.appendtext msg + EndOfLine
if instr(msg, "10A0") = 1 then
UpdateNavDisplay(msg)
elseif instr(msg, "01A0") = 1 then
MsgBox "got a response!"
elseif instr(msg, "B010") = 1 then
MsgBox "got a response!"
elseif instr(msg, "10B0") = 1 then
MsgBox "got a response!"
end

buf = Right(buf, (len(buf)-pos)-3)
end
next
Most of that is me trying to find message blocks in the Delorme protocol - at this point you can just output the seg string to see what you are receiving.

In a disconnect button action:
app.hid.close
listen.kill


Hope that helps,

_________________
http://www.miscjunk.org


Top
 Profile  
 
 Post subject: Re: Any success with MBS WinHID plugin?
PostPosted: Fri Feb 12, 2010 11:27 am 
Offline

Joined: Fri Jan 08, 2010 11:46 am
Posts: 6
Location: Dallas, TX
Thanks. This looks very similar to what I'm already doing. Still I'm getting the 1784 error when calling ReadMessage, or ReadMessageMemory. Using PollString nothing at all happens. Can't figure out how to get around that error.


Top
 Profile  
 
 Post subject: Re: Any success with MBS WinHID plugin?
PostPosted: Sat Feb 27, 2010 8:40 pm 
Offline
User avatar

Joined: Sat Nov 11, 2006 2:43 pm
Posts: 1221
Location: This poster has left the forums
EDIT - Response removed - I'm using MacHID.

_________________
%Invalidforumsignatureexception% user signature not found


Top
 Profile  
 
 Post subject: Re: Any success with MBS WinHID plugin?
PostPosted: Fri May 25, 2012 10:49 am 
Offline

Joined: Fri May 25, 2012 10:23 am
Posts: 1
I know that this reply comes a number of years after the question was asked, however, I feel that if I had known this four weeks ago I would have been further along in my process. What I have found is that the WinHIDMBS plugin works well if you do things right. The problem is that the support documents do not tell you what you need to know to get your project to work properly. I hope that what I have found works for you too.

If m.FindFirstDevice Then
Do
If m.VendorID=&h0001 Then // Find Correct Device
If m.Connect Then // Write 10 Byte Report (First Byte is Report ID Plus 9 Bytes Data)

s=chr(0)+chr(1)+chr(2)+chr(3)+chr(4)+chr(5)+chr(6)+chr(7)+chr(8)+chr(9)

i=m.SendMessage(s) [color=#4000BF]// These 2 Lines Are What Finally Got My[/color]
DelayMBS(0.3) [color=#4000BF]// Project to Work After Weeks of Frustration![/color]

Do
x=m.ReadMessage(27)
Loop Until lenb(x)>0 // Loop until we get something

MsgBox midb(x,2) // Show result in Message Box - First byte is ReportID again

m.Disconnect
End If

Else
MsgBox "PC-Peripheral Communication Error"
End If

Loop Until Not m.FindNextDevice

End If


I had sent an e-mail to MBS asking for help but got a reply which was:

First, you should start looking for errors. The WinHIDMBS class has Lasterror and LasterrorString properties.
Next, please check OutputReportByteLength for the block size you need to send (+ReportID byte).
Did you verify the device was found? Connect returns true?


Since I do understand a little bit about programming and I had been able to connect and send a few bytes of data and had checked for error messages. This was no help to me I didn't go on for what could have been weeks of e-mail messages and an offer on their part to send a device and my code. I decided to get to work and figure things out for myself and find out why I was continuing to get no productive results and could not read a message from my device. The device I was trying to get to communicate with the WinHIDMSB plugin is a PIC microcontroller with Full Speed USB capability.

The two lines of code shown were totally necessary in order to get things to work.

i=m.SendMessage(s)
DelayMBS(0.3)


The delay made all of the difference. I experimented and found that 0.3 seconds works well, but a 0.2 second delay does not work. Also, it seems that you need to handle the m.SendMessage(s) variable for some reason. I'm not sure why, but, if you do not at least do something with it you will not the message you are trying to receive from your device.

I hope that what I have found and the weeks of experimenting might be able to help you in your project.
J. Post


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group