From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Prüfsumme

Solved!
Go to solution

Hallo all,

How do i calculate Prüfsumme in labview,My code is like this..

/*****************************************************************************/

Char PROT_GetFrameCrc(Unsigned int Count, Char *Strg)

{

 

Unsigned int sum;

unsigned int i;

 

Sum = 0;

for(i=0;i<Count; i++)

sum + = Strg[i]-32;

 

 

return (char) (32+(Sum % 95));

}

 

/***************************************************************************************/

Bool PROT_CheckFrameCrc(Unsigned int Count,Char*Strg)

{

 

return (Strg[Count-1]==PROT_GetFrameCrc(Count-1,Strg))?TRUE:FALSE;

}

 

Can anyone please help me!Thank you

 

Tadhika

 

 

 

 

 

 

 

 

0 Kudos
Message 1 of 9
(2,576 Views)

I'm not going to provide code or a screenshot since i hope that you are going to learn LV by practicing with it (instead of using supplied code or "copy" screenshots).

 

You are going to need a for loop for the GetFrameCtr SubVI.

Sum would be a shift register initialized with '0'.

Indexing of Strg is done by autoindexing inputtunnel at the for loop.

Modulo is named "Quotient and Remainder" in LV.

 

That should cover all tools you need to implement your own algorithm.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 9
(2,574 Views)

hi,

i tried according to you.,what should be done inside for loop?I just started like this...(see attachment)

 

thanks.

0 Kudos
Message 3 of 9
(2,560 Views)
Solution
Accepted by topic author tadhika

Ok, some additional hints:

 

- You should change the string to an array of U8 before subtracting anything. So it is wise to do this type cast outside the loop. Pass the U8 array to the for loop as autoindexing tunnel (should be default)

- Strg[i] is this autoindexing tunnel

- You should take care of the last element of the string. Your C-code discards it.

- You have to type cast the numeric element after the loop (the code you have already wired) into a string again to have a char. I would rather simplify it and directly cast it into a boolean.

 

hope this helps,

Norbert

 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 9
(2,552 Views)

Hi,

  is it correct up to now ..what i am doing?please can u tell me more...i just started lerning labview.so i am facing difficulty..

thanks..

0 Kudos
Message 5 of 9
(2,546 Views)

i have done like this ...but i think it is somewhere wrong..

0 Kudos
Message 6 of 9
(2,537 Views)

hi,

now i succed.thanks for your help.

 

thanks.

0 Kudos
Message 7 of 9
(2,527 Views)

hi all,

   i have multiple string commands which i have to send from visa write..how can i send multiple command one after another.i am using Rs 232/rs485 serial communication.With in the string some of data i have to control from user interface.

thanks.

 

Tadhika

0 Kudos
Message 8 of 9
(2,504 Views)

Tadhika,

 

it makes sense to create a new thread for a new question instead of posting into a thread which is already answered.

 

Regarding your new question:

Please search in the LV example finder for "Advanced Serial Write and Read". While this example has more features than you require, it shows you the very basic for VISA IO.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 9 of 9
(2,487 Views)