Question about code using Full Duplex Serial
Joms
Posts: 279
I am having some problems using code with the Full Duplex Serial object, and wondering if someone can explain why this doesn't work.
Using the following code works...
Code that works is:
I copied this from the FDS object. Why wouldn't this work just in a differen't spin file?
When I use the 1 line version, I get 8F, which is what I need. My end goal is to get "8?", which is the same as 8 + 30 = 38 or "8" and F + 30 = 3F or "?".
But right now I am just trying to take small steps and learn as I go. Eventually I will to those calculations for each line, basically removing the lookup command and do the math.
Thanks in advance for help understanding this...
Using the following code works...
checksum := 655 ' hex is 28F
Code that works is:
debug.hex(checksum,2)
I copied this from the FDS object. Why wouldn't this work just in a differen't spin file?
checksum <<= (8 - 2) << 2 debug.tx(lookupz((checksum <-= 4) & $F : "0".."9", "A".."F")) debug.tx(lookupz((checksum <-= 4) & $F : "0".."9", "A".."F"))
When I use the 1 line version, I get 8F, which is what I need. My end goal is to get "8?", which is the same as 8 + 30 = 38 or "8" and F + 30 = 3F or "?".
But right now I am just trying to take small steps and learn as I go. Eventually I will to those calculations for each line, basically removing the lookup command and do the math.
Thanks in advance for help understanding this...
Comments
Your 3-line version is
It's much easier to understand if you separate things out:
Does this help? (Note that this "destroys" the value in checksum)
[code]
Sio.tx(((checksum <-= 4) & $F) + $30)
Sio.tx(13)
Sio.hex(checksum,8)
Sio.tx(13)
Sio.tx(((checksum <-= 4) & $F) + $30)
Sio.tx(13)
Sio.hex(checksum,8)
Sio.tx(13)
[\code]
Your code with the lookupz returns the ASCII value of "0".."9", "A".."F" $30 for "0", $39 for "9", $41 for "A" and $46 for "F"
John Abshier
Mike, I think I understand what is going on. I sat and spent some time, even before I posted, trying to figure out what was going on behind the scenes... The main question is, if it works in the FDS object, why wouldn't just copy and pasting it over make it work? To trouble shoot this further, I am going to try and recode it step by step like you showed in your explination. My end goal is to do the conversion per byte like I explained in the end of my first post, but I am also trying to learn how it works while I am putting it together this time. I try not to just make it work once and forget it, but learn from it so I can use bits and peices of what I learn in my next code...
John, I seem to be kind of confused about your response. Why should I send 8 charactors? I think I understand what you are trying to get at, but all I get is '0' in any debug that I do.
Thanks both of you for the help. If you have any ideas why I just keep getting a '0', please let me know...
But your help was not wasted. I am still learning, so thank you for your help!
Sio.tx(((checksum <-= 4) & $F) + $30) only prints out 1 character.
John Abshier