Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

nmea checksum

807588Jul 21 2009 — edited Jul 21 2009
I have to make nmea checksum method, that will create checksum for selected string:

the checksum value is derived by the same method of NMEA standard. its calculated by XOR the 8 bits of each character before in the sentence excluding .
The HEX value of the most significant and least significant 4 bits of the result are converted to 2 ASCII characters.

My method:
String c; 
        int checksum=0;        

	        	 for (int i = 0; i < command.length(); i++) {
	        			// if it is first value for the checksum
	    				if (i == 0)
	    				{	    			    				  					
	    					checksum = (byte)command.charAt(i);	

	    				}
	    				else
	    				{
	    					checksum = checksum ^ (byte)command.charAt(i);

	    				}

	        	 }
           
If i enter: GSC,011412000010789,M2(P3=500)

i get:

checksum: 114
Integer.toHexString(checksum): 72

I get the same result in:

+[
|http://nmeachecksum.eqth.net/]*But in the manual is the result:* +*35*

What do i have to do to get this result? I think it is someting about 4 most al least important bits? How to get them?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 18 2009
Added on Jul 21 2009
2 comments
439 views