Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 28-Jan-13 7:29am
Comments
CPallini at 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 at 28-Jan-13 14:19pm
   
What happens if you send 0x123?
What do you read back?
glennPattonWork at 29-Jan-13 4:04am
   
Okay 0x123 hex or 291 dec, sent, read back 12306 dec or 3012 hex???
glennPattonWork at 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
glennPattonWork at 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!!
supernorb at 30-Jan-13 18:33pm
   
I think you first should explain to every one what you want it to work generally, giving an input and make an output is a simple scheme. Analyze all cases which can happen for input values, pay attention to special cases ... I think it is not too complicated.
glennPattonWork at 30-Jan-13 18:44pm
   
Umm Hi, I have asked this question in a different way, supplied some more detail, drank a lot of coffee lost some hair, but thanks to Griff got it working before the dead line. Thanks Glenn

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

  Print Answers RSS
0 DamithSL 265
1 CPallini 235
2 OriginalGriff 233
3 Maciej Los 175
4 George Jonsson 170
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100