Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi All...(Particularly Original Griff!)
I have been battling a piece of hardware for some time, all I have left is to write out a value, I have manage to read from the <<Expletive Deleted>> smart card and write out to it. I have just seen the first bug If I write out a value of 255 or FF the system works. I now appear to be writing the number correctly however reading it back is the issue if I send 273 which is 111 in hex because of the oddities of this piece of hardware it needs to see it as 11100000 I have padded the string and all is well (that was due to some help by Orig. Griff and several others over Friday and this morning thanks to all) the issue now is I need to trim the string as when 11C00000 is read in it is interprited as 297795584
Value_Int = int.Parse(txtValueCredit.Text,System.Globalization.NumberStyles.HexNumber);
via that how ever the routine works fine for numbers that are less 255 (or FF!) over 255 it doesn't I am pretty sure it is to with the fact I am reading in reverse so any value that climbs over 255 such as 273 (111^16)is being read as 1110 or 11 10 and my the conversion routine above sees it as 1110 and gives 4368 how ever messing around I have found if the last character is removed with a Substring it works this does start to bother me though as the idea of chopping off a the last charcter seems a bit of a sledgehammer situation would I be better using an if to check for a 0 if its a 0 substring it if not treat it as part of the string for conversion. does that sound do-able, ah well off to the rain now I have finished for the day!
Glenn
Posted
Comments
CPallini 28-Jan-13 13:42pm    
Cannot you simply state what is the format expected by the device (what is the range accepted and how it is encoded)? Knowing that I suppose we may give a better help.
OriginalGriff 28-Jan-13 14:19pm    
What happens if you send 0x123?
What do you read back?
glennPattonWork3 29-Jan-13 4:04am    
Okay 0x123 hex or 291 dec, sent, read back 12306 dec or 3012 hex???
glennPattonWork3 29-Jan-13 4:08am    
Also if I send 10,000 credit from the device I am replacing this is read back as 10,000 by the software I have written. So the I don't think the issue is the read, I think it is with the way I am treating the write. Further looking is required!
Glenn
glennPattonWork3 29-Jan-13 5:17am    
Oh <<expletive deleted!!!>> 3012 is 1230 I need to swap the characters in pairs 30 12 becomes 12 30 and then check to see if the last bit is a zero if it is get rid of it! scratch head, more caffine!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900