Main > Software Forum
What is Mame's "generic output support system" capable of?
headkaze:
How about after this line
--- Code: ---Call CopyMemory(data, ByVal copydata.lpData, copydata.cbData)
--- End code ---
Loop through each byte of sString until you hit a null character outputting them as an ascii integer value followed by it's char equivilent. At least then we know it's not the conversion to unicode thats messing it up.
Eg. The output would be
65:A
66:B
67:C
Howard_Casto:
well the data i get back is pretty much all nulls
I get a null, a single or sometimes double letter, followed by nulls (which is expected because we've created a 256 character array)
headkaze:
Can you get copydata_id_string.id okay or is that garbage as well? In that case I would suggest it's a problem with some other part of your code. Maybe you don't have your listener window setup properly. VB6 is a bit funny with subclassing as well, from memory you can't even subclass within the IDE without it crashing.
You can check the memory addresses in COPYDATASTRUCT are received correctly by modifying ledutil to output the addresses when it receives them in Aaron's program.
Then output them the same in your test program and compare addresses. If they are in the same range it should mean the addresses are received okay. If they appear as garbage it should be clear that it's garbage and not being received properly.
I guess the only way to figure out where it's not working is to back track through the code and test each part as it happens by comparing expected output from the ledutil util. Attached is a VC++6 console version of ledutil with debug enabled, and I've added an extra output to show the addresses in the COPYDATASTRUCT so you can check them against the addresses your receiving.
Howard_Casto:
That was useful, thanks....
hmm it seems vb is doing some auto format conversion... my guess is that is what is causing the screwups when it recycles the gotten data to read those chunks and break it down into the data we need.
Note below how it's hex in ledutil and integer in my app (I'm not doing any conversions)
--- Code: ---LedUtil Output:....
Using PS/2 method
mame_start (0D4F04C8)
copydata (0D4F04C8)
copydata.dwData (00000001) copydata.cbData (0000000E) copydata.lpData (0012FDB0)
id 0 = 'digdug'
======================
My apps Output:....
copydata: 1309576
copydata.dwdata 1 copydata.cbdata 8 copydata.lpdata 1309600
--- End code ---
Now the question is what to do about it.
headkaze:
I think I've found the error in the code. Although your outputs look wrong and they shouldn't be. I've been assuming that char string[1]; is actually 1 byte, but it's not, it's a pointer to a string of chars, meaning it's 4 bytes. Hence why the cbData is 0xE which is not what I expected. So I added some more debug output.
--- Code: ---Using PS/2 method
mame_start (001A0878)
copydata (001A0878)
copydata.dwData (00000001) copydata.cbData (0000000E) copydata.lpData (0012FDB0)
sizeof(*data) (00000008) strlen(data->string) (00000006) sizeof(*data) + strlen(
data->string) (0000000E)
id 0 = 'digdug'
mame_stop (001A0878)
--- End code ---
And here it's finally clear what's going wrong. sizeof(*data) tells us that copydata_id_string is in fact 8 bytes long. Sorry, this was my mistake I should have realised the array of chars is a pointer. If it was defined as char string; then it would be 1 byte long, but char string[1]; means it's a pointer (4 bytes), same as char *string;. Okay now we have that out of the way, it's clear why your decoding the string fails because your decoding a pointer address! Hence why you get a few garbage characters 4 bytes long.
Try this new approach...
--- Code: ---Private Type COPYDATASTRUCT
dwData As Long
cbData As Long
lpData As Long
End Type
Private Type copydata_id_string
id As Long
lpString As Long
End Type
Sub handle_copydata(lParam As Long)
Dim sString As String
Dim copydata As COPYDATASTRUCT
Dim data As copydata_id_string
Dim buf(0 To 255) As Byte
Call CopyMemory(copydata, ByVal lParam, Len(copydata))
Call CopyMemory(data, ByVal copydata.lpData, Len(data)))
Call CopyMemory(buf, ByVal data.lpString, copydata.cbData - Len(data))
sString = StrConv(buf, vbUnicode)
sString = Left$(sString, InStr(0, sString, Chr$(0)) - 1)
frmReceive.lblString = sString
End Sub
--- End code ---
See if that works.
EDIT: It still dosn't explain why your getting copydata.cbdata as 8 (0x8). It should be 14 (0xE) but that could be a problem somewhere else in your code. You may need to send me the source so I can check the rest out. I'm pretty sure the above code is correct now though.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version