Jump to content
  • 0

Waveforms Protocol import "hex" - bug?


CircuitNinja

Question

 

tl;dr see image attached, I hope it better describes the issue I am facing.

 

I have a large buffer I would like to write, using I2C Protocol module.  I can manually send hex values to the device correctly by inputting the hex values into the write buffer manually, e.g. h00, hA5, hFF.  However the feature to load the buffer from a text or bin file has proven problematic for me.

So I am aware that hex values require to be prepended with "h" when inputted to the write buffer, (this becomes especially important for ambiguous values which could be either decimal or hex (e.g. h18 to ensure hex 0x18)    However, I have not found a way to successfully indicate to Waveforms that the values imported from the text or bin file are to be loaded pre-pended with "h".   It always loads the values as though they were decimal.

I have tried placing h18 for example in the txt file, but waveforms just chokes and doesn't load the buffer, when I add the "h".  I have also tried to write a "binary" file.  Where all values should be interpreted as hex.  However, waveforms loads the input buffer from the file once again without the "h" add to each byte in the buffer.  

This leads to the issue of values being interpreted as decimal (base 10) rather than hex.  Example: The "hex" value x18 in the binary file turns into hex 0x12 when actually written to i2c.

> Is there something I am missing, is there a special format I can use in the txt file to have waveforms load the buffer with "h" prepended to the values?  

Alternately this may be a bug, and in that case I would suggest either an option to indicate to read all values from the loaded file as "hex" values - aka... prepend each value in the buff with "h" - or maybe Waveforms can be made smart enough to know that if "binary" file type is chosen in the dropdown to load the buffer correctly, with h.... for each byte.

 

image.thumb.png.5cd959fca1c26953086cfbc8188b8d22.png

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hi @CircuitNinja

The interpretation is by default base 10, for hexadecimal 'h' or '0x' prefix should be used and 'b' for binary.

You could use a script like this to load a text file with space delimited hex values:
Protocol.I2C.WriteText.text = "h"+(""+FileRead("~/Desktop/hex.txt")).split(" ").join(" h");

image.png

 

To send it directly use:
var rg = [];
(""+FileRead("~/Desktop/hex.txt")).split(" ").forEach(function(sz){rg.push(parseInt(sz,16))});
Write(0x12, rg);

image.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...