http://imagej.273.s1.nabble.com/Problem-sending-unsigned-byte-as-string-via-Serial-Macro-Extensions-tp3687446p3687449.html
it is easy - the sources are in the .jar file.
A .jar file is a .zip file (with a different name).
modification in the code, and use 'Compile and Run' of ImageJ.
one. That's it. (You may rename it back to .jar, but that's not
> Hi Michael,
>
> Thanks for getting back to me so soon.
>
> Unfortunately, I am not a java programmer, and am just a newbie at
> writing ImageJ macros, so I'm afraid I don't know how to do what you
> suggest. However, I do have a basic knowledge of programming
> principles...
>
> So far, I have merely downloaded the serial macro extensions from the
> ImageJWIKI and then followed the instructions! The only file involved
> in that that is close to what you mention is "serial_ext.jar". Can
> this
> be modified in the way that you suggest, and if so, what can be
> used to
> edit it?
>
> Sorry to be so far off the pace!
>
> Graeme
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of
> Michael Schmid
> Sent: 28 July 2010 18:20
> To:
[hidden email]
> Subject: Re: Problem sending unsigned byte as string via "Serial Macro
> Extensions"
>
> Hi Graeme,
>
> serial_ext.java uses String.getBytes() to convert the String into a
> sequence of bytes. From the Java Website:
>
> public byte[] getBytes()
> Encodes this String into a sequence of bytes using the platform's
> default charset, storing the result into a new byte array.
> The behavior of this method when this string cannot be encoded in the
> default charset is unspecified.
> So I would suggest that you change the code in serial_ext.java,
> roughly like this:
>
> public void write(String s) {
> byte[] bytes = new byte[s.length()];
> for (i=0; i<s.length(); i++)
> bytes[i] = (byte)(s.charAt(i));
> write(bytes);
> }
>
>
> Michael
> ________________________________________________________________
>
> On 28 Jul 2010, at 18:08, Graeme Awcock wrote:
>
>> I have been trying to output binary data (just an 8-bit unsigned
>> character)
>> from the ImageJ macro language in a form that can be sent over a
>> serial
>> link. I want to develop hardware that will use the data byte to
>> control a
>> DAC, for example. The problem is that a range of 16 values are being
>> filtered out and replaced by another value...
>> I am using the "Serial Macro Extensions" as provided on the
>> ImageJWIKI to
>> control the serial port.
>> Mostly this works well, but something in the chain is 'filtering'
>> out values
>> in the range 80-9F hex. Instead the serial data in that range is
>> forced to
>> 3F hex (confirmed by hardware testing).
>> I am aware that this range of binary values corresponds to a block of
>> control codes in Unicode/ASCII, so this seems like a likely
>> motivation for
>> the problem, but I need to get around it because I obviously want
>> to be able
>> to send all 256 possible values for the byte over the serial link.
>> I am using the built-in ImageJ macro function "fromCharCode
>> (value)" to
>> convert 'value' from hex to a string character. I do not know
>> whether this
>> function is filtering the characters 80-9F hex, or if it is
>> happening within
>> the serial macro extension code.
>> Can anyone help. please?
>
> ___________________________________________________________
> This email has been scanned by MessageLabs' Email Security
> System on behalf of the University of Brighton.
> For more information see
http://www.brighton.ac.uk/is/spam/> ___________________________________________________________
>
> ___________________________________________________________
> This email has been scanned by MessageLabs' Email Security
> System on behalf of the University of Brighton.
> For more information see
http://www.brighton.ac.uk/is/spam/> ___________________________________________________________