LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calculate CRC16 (my algoritm)

Solved!
Go to solution

Can you please tell how to calculate the CRC. on this code:

 

unsigned short CRC16(unsigned short crc, unsigned char byte)
{
unsigned short carry;

carry = 0xFF & ((crc >> 😎 ^ byte);
carry = carry ^ (carry >> 4);
return ((crc ^ (carry << 4) ^ (carry >> 3)) << 😎 ^ ((carry ^ (carry << 5)) & 0xFF);
}

 

 

 

Thank you!

0 Kudos
Message 1 of 7
(3,745 Views)

Hi Sergiv,

 

you will find a lot of "calculate CRC" threads in the forum! Did you look for and did you check their examples?

 

Did you know

- you can use boolean logic on integer numbers like U8?

- you can do shifts using "logical shift" function (in the numerics palette)?

 

Following those two advices it should be easy to convert that C code into LabVIEW/G...

 

(Can't look at your VI due to the LabVIEW version you use.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(3,742 Views)

thanks for the answer 

 

I tried to make the example, but I did not succeed.

I never programiroval in C.

 

resave your vi in version 8.6so, and I ask for your help

0 Kudos
Message 3 of 7
(3,738 Views)
Solution
Accepted by Sergiv

Hi Sergiv,

 

I don't claim "it's correct now" but I tried to follow your C algorithm...

 

Due to upload problems (forum doesn't accept VIs anymore...) I had to change filename from "*.vi" to "*-vi"!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 7
(3,732 Views)

thank you

0 Kudos
Message 5 of 7
(3,727 Views)

@GerdW wrote:

forum doesn't accept VIs anymore...


When this happened??

I have attached a VI, couple of minutes back...!! Smiley Surprised


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 6 of 7
(3,721 Views)

Hi moderator,

 

it happened at the time given in the message header...

 

This happens for me since some days and I already complained in the "Forum feedback" thread (as several other people too)!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 7
(3,711 Views)