FW: Jawin, P instruction

"Mcnamara, Sean D" <[email protected]> Thu, 24 Aug 2006 08:24:06 -0400
Newsgroups gmane.comp.windows.devel.jawin
Message-ID <57F935D6BB6B2543AF5D835DCE7CAF2702A259C2@MD61EX100.ad.honeywell-tsi.com>
Posting this for Vitaliy due to his issues with registering for the =
mailing list. He can use the web interface for read access, so if anyone =
replies, I'll just send him an e-mail reminder.

His problem is a little bit over my head -  something tells me it's over =
Jawin's head, too, since I've seen discussions like this come and go =
through the mailing list without any surefire solution. The struct he =
uses complicates things - would be nice to see a C++-formatted declare =
(an H file or such)... Oh well...

-Sean

-----Original Message-----
From: Vitaliy Vdovychenko [mailto:[email protected]]=20
Sent: Thursday, August 24, 2006 4:51 AM
To: Mcnamara, Sean D
Subject: RE: Jawin, P instruction

Hello Sean , thank's for your response:-) I've tryed to register my mail =
on the Jawin mailing list but i didn'd get the respons about my passwort =
registration, that is why i thougt to write an e-mail to you. So, now I =
try to describe my problem.

# I have some dll as bin formated, so i can't change it.
# I have a function, the function has an input parameter - byte [], this =
byte[] is converted from a structure, this byte[] will be then filled up =
by the function and I need now read a pointer which points to this  =
byte[] wit a new data by the native function .
# the  native function looks like this:

xlCanTransmit(XLportHandle, xlAccessMask, int *messageCount, void =
*pMessages)

XLportHandle - is an Integer [in]
xlAccessMask - is an Integer [in]
*messageCount - int Points to the amount of messages, which schould be =
send and return the number of transmited messages, I ve used "A" string =
and "n4" to read a pointer.
*pMessages - points to user buffer with messages to be send. Al least =
the buffer must have the size oj messageCount. here i've used "P", but i =
havnt have any idea how can i read back this pointer to byte[].


pMessages is a structure which looks like this:

public static class xl_event extends Object{
        public byte tag;
                public char channelIndex;
                public short transId;
                public short portHandle;
                public short reserved;
                public long timeStamp;=09
                public StructureClass.xl_can_message tagData =3D new =
StructureClass.xl_can_message();
=09

        }

I've transformed this structure in byte [] and wrote it to the native =
function, now i need to read the buffer back in this byte[], i tryed to =
do this with a P instruction, my Java Code looks like this:

public static int JxlCanTransmit(int portHandle, int accessMask, int =
messageCount, byte [] pMessages)throws Exception {
        FuncPtr jct =3D null;
        try
        {
        jct =3D new FuncPtr ("vxlapi.dll", "xlCanTransmit");
        NakedByteStream nbs =3D new NakedByteStream();
        LittleEndianOutputStream leos =3D new LittleEndianOutputStream(nbs);
//      4x[in]=20
=09

        leos.writeInt(portHandle);
        leos.writeInt(accessMask);
=09
        leos.writeInt(messageCount);

        for (int loop =3D0; loop<pMessages.length; loop++)
            {
                leos.writeByte(pMessages[loop]);
                }
=09
String  marshal =3D"IIA"+"P"+pMessages.length+":I:n16" ;


byte[] result=3Djct.invoke(marshal,24,nbs,null,ReturnFlags.CHECK_FALSE);

LittleEndianInputStream leis =3D new LittleEndianInputStream(new =
ByteArrayInputStream(result)); //1x[retval] int XLStatus =3D =
leis.readInt();

messageCount=3Dleis.readInt();
return XLStatus;

!!!!!! at this stage i need to get my pointer to my [in] byte [] and =
read it out, than i convert it again in Structure back, and get my =
structure with new data }
        catch (COMException e) {
                // handle exception
                e.printStackTrace();
                throw e;
        } finally {
                if ( jct !=3D null) {
                        try {
                                jct.close();
                        } catch (COMException e) {
                                // handle fatal exception
                                e.printStackTrace();
                                throw e;
                        }
                }
        }
        }



I hope i described a problem a little bit, and i hope you will help me.
Thank you for your respons and excuseme that i  disrupt your work with =
my problems:-)=20

Best regards, Vitaliy V.




> -----Urspr=FCngliche Nachricht-----
> Von: "Mcnamara, Sean D" <[email protected]>
> Gesendet: 24.08.06 05:54:23
> An: "Vitaliy Vdovychenko" <[email protected]>
> Betreff: RE: Jawin, P instruction


> 1. Can you please post some code related to what you're trying to do?=20
> If you derived it from an example from the jawinproject documentation, =

> please include the URL of the example.
>=20
> 2. Please reply to the whole mailing list, not just to me. Others may=20
> be able to help too. Include or attach this message and your original=20
> request.
>=20
> 3. I'd like to understand your ultimate goal here. I'm assuming you=20
> have some C++ code that returns little-endian-formatted C++ "bytes"=20
> (which should map as far as size and sign to Java bytes, we hope.) Do=20
> you want to *use*, in Java, the address/pointer itself, or do you want =

> to retrieve the contents of the byte array? Retrieving the contents is =

> much easier than attempting to retrieve the pointer, deserializing the =

> array, then serializing it back into C++ format to modify the contents =

> of the array's values in memory.
>=20
> If all you want to do is retrieve the values into a Java byte[], see=20
> http://jawinproject.sourceforge.net/jawinuserguide_dll.html -- in=20
> particular, the reference to the NakedByteStream being passed into the =

> generic invoke method provides a way to "convert" C++ byte arrays into =

> Java byte[]. Then, section 3.2.1 of the linked page describes how to=20
> create the byte[] from a valid NakedByteStream.
>=20
> I'm pretty sure you won't be using any raw InputStreams, although you=20
> do use classes extending/implementing that.
>=20
> -Sean
>=20
> -----Original Message-----
> From: Vitaliy Vdovychenko [mailto:[email protected]]
> Sent: Wednesday, August 23, 2006 6:06 PM
> To: Mcnamara, Sean D
> Subject: Jawin, P instruction
>=20
> Hello Sean, excuse me but i saw your mai in the Jawin mailing list, I' =

> a studen from  TU-Dresden, and i'm trying use Jawin to communicate=20
> with
> c++ dll, I have the same problem as you wrote to the "jawin help" my
> native function returns a pointer to the byte[] , I used P=20
> instruction, but I have a problem how can i read the byte[] pointer=20
> with a InputStream? Could you please help me ?
>=20
> Thank's!
> Best regards, Vitaliy