Welcome, Guest. Please login or register.
November 22, 2024, 01:34:22 PM

Login with username, password and session length
* Home Help Arcade Login Register
.
+  Forum
|-+  Homebrew Player Tracking and EFT Systems.
| |-+  NLG Homebrew Player Tracking and EFT Systems.
| | |-+  SAS CRC algorithm C# .NET
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Print
Author Topic: SAS CRC algorithm C# .NET  (Read 11315 times)
JonaMX
Guest
« on: July 16, 2011, 05:21:17 PM »

Does anyone has the CRC SAS algorithm ??

I don't know how to implement in C# the one that includes IGT SAS 6.02 document  (attached picture)  Scratch Head



* CRC.PNG (46.73 KB, 694x532 - viewed 990 times.)
Logged
zarobhr
Contributing Gold NLG Member
Sr.NLG Member 501 to 1000 Post
*

Total Karma Storms: 178
Offline Offline

Gender: Male
Posts: 622



« Reply #1 on: July 16, 2011, 05:29:17 PM »

i hvae one that works in c#i will have to post itfrom the other pc
Logged
JonaMX
Guest
« Reply #2 on: July 16, 2011, 05:33:01 PM »

i hvae one that works in c#i will have to post itfrom the other pc
thanks I'll waiting it
Logged
zarobhr
Contributing Gold NLG Member
Sr.NLG Member 501 to 1000 Post
*

Total Karma Storms: 178
Offline Offline

Gender: Male
Posts: 622



« Reply #3 on: July 16, 2011, 05:40:26 PM »

here you go i use this to both compute the crc when sending commands and to compute the crc on recieved data to make sure the recieved crc is valid
in order for  this to work the byte[] cannot include the crc bytes

Code:
public  static byte[] ComputeCRC(byte[] val)
        {
            long crc;
            long q;
            byte c;
            crc = 0;
            for (int i = 0; i < val.Length; i++)
            {
                c = val[i];
                q = (crc ^ c) & 0x0f;
                crc = (crc >> 4) ^ (q * 0x1081);
                q = (crc ^ (c >> 4)) & 0xf;
                crc = (crc >> 4) ^ (q * 0x1081);
            }
            return new byte[] { (byte)(crc & 0xff),(byte)(crc >> 8) };
           
        }




Moderator: I enclosed your code in an SMS code block, because the command  "c = val [ i ];" was interpreted by the forum software as an italic command. SF garfield
« Last Edit: July 16, 2011, 06:59:47 PM by StatFreak » Logged
JonaMX
Guest
« Reply #4 on: July 16, 2011, 05:47:22 PM »

here you go i use this to both compute the crc when sending commands and to compute the crc on recieved data to make sure the recieved crc is valid
in order for  this to work the byte[] cannot include the crc bytes

public  static byte[] ComputeCRC(byte[] val)
        {
            long crc;
            long q;
            byte c;
            crc = 0;
            for (int i = 0; i < val.Length; i++)
            {
                c = val;
                q = (crc ^ c) & 0x0f;
                crc = (crc >> 4) ^ (q * 0x1081);
                q = (crc ^ (c >> 4)) & 0xf;
                crc = (crc >> 4) ^ (q * 0x1081);
            }
            return new byte[] { (byte)(crc & 0xff),(byte)(crc >> 8) };
           
        }

Thanks zarobhr I'll use it and comeback to tell you how it works
Logged
JonaMX
Guest
« Reply #5 on: July 16, 2011, 06:05:52 PM »

It works pretty well thanks again zarobhr  Hail applause
Logged
StatFreak
rotaredoM etiS GLN labolG
Global NLG Site Moderator
Sr.Tech NLG Member 1000+ Post
*

Total Karma Storms: 756
Offline Offline

Gender: Male
Posts: 8549


Warning! Spammers will be eaten, with relish!


« Reply #6 on: July 16, 2011, 06:52:39 PM »

It works pretty well thanks again zarobhr  Hail applause

Thanks for letting us know.  applause +1 (Karma, or whatever)  I'm assuming that you found the little glitch in the code displayed in the post, which I just corrected.
I noticed that your original code was using the value 17d, instead of 15d, which is equal to 0x0f.


Stat garfield
Logged

I found myself at NLG garfield  ..but got lost again on the way home. Scratch Head 2
If found, please email me to myself. Thanks. yes
       Executive member in good standing of Rick's SMAA.                              Ehhh...What's Up Doc?
zarobhr
Contributing Gold NLG Member
Sr.NLG Member 501 to 1000 Post
*

Total Karma Storms: 178
Offline Offline

Gender: Male
Posts: 622



« Reply #7 on: July 16, 2011, 06:55:49 PM »

aw is that the icon that looks like a # sign
Logged
StatFreak
rotaredoM etiS GLN labolG
Global NLG Site Moderator
Sr.Tech NLG Member 1000+ Post
*

Total Karma Storms: 756
Offline Offline

Gender: Male
Posts: 8549


Warning! Spammers will be eaten, with relish!


« Reply #8 on: July 16, 2011, 06:58:37 PM »

aw is that the icon that looks like a # sign

Yes it is. As you can probably tell, it doesn't get much use around here. rotflmao rotflmao
BTW, I gane you a  +1 (Karma, or whatever) too.
Logged

I found myself at NLG garfield  ..but got lost again on the way home. Scratch Head 2
If found, please email me to myself. Thanks. yes
       Executive member in good standing of Rick's SMAA.                              Ehhh...What's Up Doc?
zarobhr
Contributing Gold NLG Member
Sr.NLG Member 501 to 1000 Post
*

Total Karma Storms: 178
Offline Offline

Gender: Male
Posts: 622



« Reply #9 on: July 16, 2011, 07:01:23 PM »

aw is that the icon that looks like a # sign

Yes it is. As you can probably tell, it doesn't get much use around here. rotflmao rotflmao
BTW, I gane you a  +1 (Karma, or whatever) too.

thanks
Logged
JonaMX
Guest
« Reply #10 on: July 16, 2011, 07:29:59 PM »

It works pretty well thanks again zarobhr  Hail applause

Thanks for letting us know.  applause +1 (Karma, or whatever)  I'm assuming that you found the little glitch in the code displayed in the post, which I just corrected.
I noticed that your original code was using the value 17d, instead of 15d, which is equal to 0x0f.


Stat garfield

Yeah in fact it is

c=val[ i ];

Not c=val;
 +1 (Karma, or whatever)
Logged
StatFreak
rotaredoM etiS GLN labolG
Global NLG Site Moderator
Sr.Tech NLG Member 1000+ Post
*

Total Karma Storms: 756
Offline Offline

Gender: Male
Posts: 8549


Warning! Spammers will be eaten, with relish!


« Reply #11 on: July 16, 2011, 07:55:09 PM »

Well, you wouldn't have much of a recursive "For/While" loop if there were no "i".  Sherlock Smiley   Crazy bust gut laughing bust gut laughing bust gut laughing
Logged

I found myself at NLG garfield  ..but got lost again on the way home. Scratch Head 2
If found, please email me to myself. Thanks. yes
       Executive member in good standing of Rick's SMAA.                              Ehhh...What's Up Doc?
stayouttadabunker
Senior Full time Member.
Sr.Tech NLG Member 1000+ Post
*

Total Karma Storms: 1039
Offline Offline

Gender: Male
Posts: 13447



« Reply #12 on: July 17, 2011, 01:26:57 AM »

I gave all you guys a + Karma!  Hail
Great little thread! yes
Logged
Pages: [1] Go Up Print 
« previous next »
Jump to:  


If you find this site helpful, Please Consider Making a small donation to help defray the cost of hosting and bandwidth.



Newlifegames.com    Newlifegames.net    Newlifegames.org
   New Life Games    NewLifeGames  NLG  We Bring new Life to old Games    1-888-NLG-SLOTS
Are all Copyright and Trademarks of New Life Games LLC 1992 - 2021


FAIR USE NOTICE:

This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner.
We make such material available in an effort to advance awareness and understanding of the issues involved.
We believe this constitutes a fair use of any such copyrighted material as provided for in section 107 of the US Copyright Law.
In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit to those
who have expressed a prior interest in receiving the included information for research and educational purposes.

For more information please visit: http://www.law.cornell.edu/uscode/17/107.shtml.

If you wish to use copyrighted material from this site for purposes of your own that go beyond fair use,
you must obtain permission directly from the copyright owner.

NewLifeGames.net Web-Site is optimized for use with Fire-Fox and a minimum screen resolution of 1280x768 pixels.


Powered by SMF 1.1.20 | SMF © 2013, Simple Machines
Loon Designed by Mystica
Updated by Runic Warrior
Page created in 0.102 seconds with 20 queries.