Re: [Tinyos-help] CRC Checking

2009-04-13 Thread JeongGil Ko (John Ko)
Hi!

You should be able to find where the packet is dropped due to CRC errors 
in CC2420ReceiveP.nc.

-John

Joe Green wrote:
> Is there a way to remove the CRC checking from the motes? I am trying 
> to implement a different type of error correction, but do not know 
> if/where to make the edits.
>
> 
>
> ___
> Tinyos-help mailing list
> Tinyos-help@millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

-- 
JeongGil (John) Ko
Ph.D. Student
Department of Computer Science
Johns Hopkins University
http://cs.jhu.edu/~jgko

___
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


Re: [Tinyos-help] CRC checking

2007-04-08 Thread Michael Schippling

This site describes the message format and CRC calculation:
http://www.octavetech.com/pubs/TB5-01%20Deciphering%20TinyOS%20Serial%20Packets.pdf

There's also code in TOS (well...duh) and the java tools which
does the CRC. I know one is called crc.java

MS

jurin dan wrote:
 
hi,
 
i have the raw data packet below receive with xlisten app:
 


*$ xlisten -r -b=mica2 -s=COM4 -t*

*xlisten Ver:$Id: xlisten.c,v 1.2 2005/06/21 01:36:06 pipeng Exp $*

*Using params: [baud=0x1001] [raw] [timed]*

*COM4 input stream opened*

*[2007/04/04 10:40:35]*

*7e42007d5d1d840101009101710031037d5d023003007964 
[40]*


 
CRC = 0x6479 (last bytes)
 
i woul like to know how i could use the CRC to check the integrity of 
the transmitted packet.

and which byte of the packet are taking in acount to compute the CRC.
 
thanx for your help




Invite your mail contacts to join your friends list with Windows Live 
Spaces. It's easy! Try it! 






___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


RE: [Tinyos-help] CRC checking

2007-04-09 Thread jurin dan
thanks a lot for your reply.
 
just one more thing. within the raw data packet, which byte do i use to compute 
the CRC.
is it all byte or only TOS_MSG byte.
 
 



> Date: Sun, 8 Apr 2007 17:22:29 -0600> From: [EMAIL PROTECTED]> To: [EMAIL 
> PROTECTED]> CC: tinyos-help@Millennium.Berkeley.EDU> Subject: Re: 
> [Tinyos-help] CRC checking> > This site describes the message format and CRC 
> calculation:> 
> http://www.octavetech.com/pubs/TB5-01%20Deciphering%20TinyOS%20Serial%20Packets.pdf>
>  > There's also code in TOS (well...duh) and the java tools which> does the 
> CRC. I know one is called crc.java> > MS> > jurin dan wrote:> > > > hi,> > > 
> > i have the raw data packet below receive with xlisten app:> > > > > > *$ 
> xlisten -r -b=mica2 -s=COM4 -t*> > > > *xlisten Ver:$Id: xlisten.c,v 1.2 
> 2005/06/21 01:36:06 pipeng Exp $*> > > > *Using params: [baud=0x1001] [raw] 
> [timed]*> > > > *COM4 input stream opened*> > > > *[2007/04/04 10:40:35]*> > 
> > > 
> *7e42007d5d1d840101009101710031037d5d023003007964
>  > > [40]*> > > > > > CRC = 0x6479 (last bytes)> > > > i woul like to know 
> how i could use the CRC to check the integrity of > > the transmitted 
> packet.> > and which byte of the packet are taking in acount to compute the 
> CRC.> > > > thanx for your help> > > > > > 
> > > 
> Invite your mail contacts to join your friends list with Windows Live > > 
> Spaces. It's easy! Try it! > > 
> <http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us>>
>  > > > > > 
> > > > 
> > ___> > Tinyos-help mailing 
> list> > Tinyos-help@Millennium.Berkeley.EDU> > 
> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Re: [Tinyos-help] CRC checking

2007-04-09 Thread Michael Schippling

I thing that's in the octavetech page, but I believe it is all bytes
including header, before escapes are applied.
I'm not sure but I think the pre-amble 7E 4x is not included.

MS

jurin dan wrote:


thanks a lot for your reply.
 
just one more thing. within the raw data packet, which byte do i use to 
compute the CRC.

is it all byte or only TOS_MSG byte.
 




 



 > Date: Sun, 8 Apr 2007 17:22:29 -0600
 > From: [EMAIL PROTECTED]
 > To: [EMAIL PROTECTED]
 > CC: tinyos-help@Millennium.Berkeley.EDU
 > Subject: Re: [Tinyos-help] CRC checking
 >
 > This site describes the message format and CRC calculation:
 > 
http://www.octavetech.com/pubs/TB5-01%20Deciphering%20TinyOS%20Serial%20Packets.pdf

 >
 > There's also code in TOS (well...duh) and the java tools which
 > does the CRC. I know one is called crc.java
 >
 > MS
 >
 > jurin dan wrote:
 > >
 > > hi,
 > >
 > > i have the raw data packet below receive with xlisten app:
 > >
 > >
 > > *$ xlisten -r -b=mica2 -s=COM4 -t*
 > >
 > > *xlisten Ver:$Id: xlisten.c,v 1.2 2005/06/21 01:36:06 pipeng Exp $*
 > >
 > > *Using params: [baud=0x1001] [raw] [timed]*
 > >
 > > *COM4 input stream opened*
 > >
 > > *[2007/04/04 10:40:35]*
 > >
 > > 
*7e42007d5d1d840101009101710031037d5d023003007964 


 > > [40]*
 > >
 > >
 > > CRC = 0x6479 (last bytes)
 > >
 > > i woul like to know how i could use the CRC to check the integrity of
 > > the transmitted packet.
 > > and which byte of the packet are taking in acount to compute the CRC.
 > >
 > > thanx for your help
 > >
 > >
 > > 


 > > Invite your mail contacts to join your friends list with Windows Live
 > > Spaces. It's easy! Try it!
 > > 
<http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us>

 > >
 > >
 > > 


 > >
 > > ___
 > > Tinyos-help mailing list
 > > Tinyos-help@Millennium.Berkeley.EDU
 > > 
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help




Get news, entertainment and everything you care about at Live.com. Check 
it out! <http://www.live.com/getstarted.aspx >

___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


Re: [Tinyos-help] CRC checking

2007-04-09 Thread Sankar Gorthi
When we were calculating the CRC algorithm using LabVIEW, we did the 
following:


1. create the message packet including everything but the Sync bytes (7E)
2. escape the bytes corresponding to 7D, or 7E
3. run the CRC algorithm on the escaped data packet
4. attach the CRC in little endian format (lower byte first)
5. attach the sync bytes
6. Send.

I hope I got that right.

Sankar.

- Original Message - 
From: "Michael Schippling" <[EMAIL PROTECTED]>

To: "jurin dan" <[EMAIL PROTECTED]>
Cc: "tinyos-help@Millennium.Berkeley.EDU" 


Sent: Monday, April 09, 2007 12:13 PM
Subject: Re: [Tinyos-help] CRC checking



I thing that's in the octavetech page, but I believe it is all bytes
including header, before escapes are applied.
I'm not sure but I think the pre-amble 7E 4x is not included.

MS

jurin dan wrote:


thanks a lot for your reply.
 just one more thing. within the raw data packet, which byte do i use to 
compute the CRC.

is it all byte or only TOS_MSG byte.
 

 > Date: Sun, 8 Apr 2007 17:22:29 -0600
 > From: [EMAIL PROTECTED]
 > To: [EMAIL PROTECTED]
 > CC: tinyos-help@Millennium.Berkeley.EDU
 > Subject: Re: [Tinyos-help] CRC checking
 >
 > This site describes the message format and CRC calculation:
 > 
http://www.octavetech.com/pubs/TB5-01%20Deciphering%20TinyOS%20Serial%20Packets.pdf

 >
 > There's also code in TOS (well...duh) and the java tools which
 > does the CRC. I know one is called crc.java
 >
 > MS
 >
 > jurin dan wrote:
 > >
 > > hi,
 > >
 > > i have the raw data packet below receive with xlisten app:
 > >
 > >
 > > *$ xlisten -r -b=mica2 -s=COM4 -t*
 > >
 > > *xlisten Ver:$Id: xlisten.c,v 1.2 2005/06/21 01:36:06 pipeng Exp $*
 > >
 > > *Using params: [baud=0x1001] [raw] [timed]*
 > >
 > > *COM4 input stream opened*
 > >
 > > *[2007/04/04 10:40:35]*
 > >
 > > 
*7e42007d5d1d840101009101710031037d5d023003007964 
 > > [40]*

 > >
 > >
 > > CRC = 0x6479 (last bytes)
 > >
 > > i woul like to know how i could use the CRC to check the integrity 
of

 > > the transmitted packet.
 > > and which byte of the packet are taking in acount to compute the 
CRC.

 > >
 > > thanx for your help
 > >
 > >
 > 
 > 
 > > Invite your mail contacts to join your friends list with Windows 
Live

 > > Spaces. It's easy! Try it!
 > > 
<http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us>

 > >
 > >
 > 
 > 

 > >
 > > ___
 > > Tinyos-help mailing list
 > > Tinyos-help@Millennium.Berkeley.EDU
 > > 
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help




Get news, entertainment and everything you care about at Live.com. Check 
it out! <http://www.live.com/getstarted.aspx >





___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


Re: [Tinyos-help] CRC checking

2007-04-09 Thread Michael Schippling

you'll want to double check the inclusion of escape bytes,
I think CRC happens _before_ escape...
MS


Sankar Gorthi wrote:
When we were calculating the CRC algorithm using LabVIEW, we did the 
following:


1. create the message packet including everything but the Sync bytes (7E)
2. escape the bytes corresponding to 7D, or 7E
3. run the CRC algorithm on the escaped data packet
4. attach the CRC in little endian format (lower byte first)
5. attach the sync bytes
6. Send.

I hope I got that right.

Sankar.

- Original Message - From: "Michael Schippling" <[EMAIL PROTECTED]>
To: "jurin dan" <[EMAIL PROTECTED]>
Cc: "tinyos-help@Millennium.Berkeley.EDU" 


Sent: Monday, April 09, 2007 12:13 PM
Subject: Re: [Tinyos-help] CRC checking



I thing that's in the octavetech page, but I believe it is all bytes
including header, before escapes are applied.
I'm not sure but I think the pre-amble 7E 4x is not included.

MS

jurin dan wrote:


thanks a lot for your reply.
 just one more thing. within the raw data packet, which byte do i use 
to compute the CRC.

is it all byte or only TOS_MSG byte.
  



 > Date: Sun, 8 Apr 2007 17:22:29 -0600
 > From: [EMAIL PROTECTED]
 > To: [EMAIL PROTECTED]
 > CC: tinyos-help@Millennium.Berkeley.EDU
 > Subject: Re: [Tinyos-help] CRC checking
 >
 > This site describes the message format and CRC calculation:
 > 
http://www.octavetech.com/pubs/TB5-01%20Deciphering%20TinyOS%20Serial%20Packets.pdf 


 >
 > There's also code in TOS (well...duh) and the java tools which
 > does the CRC. I know one is called crc.java
 >
 > MS
 >
 > jurin dan wrote:
 > >
 > > hi,
 > >
 > > i have the raw data packet below receive with xlisten app:
 > >
 > >
 > > *$ xlisten -r -b=mica2 -s=COM4 -t*
 > >
 > > *xlisten Ver:$Id: xlisten.c,v 1.2 2005/06/21 01:36:06 pipeng Exp $*
 > >
 > > *Using params: [baud=0x1001] [raw] [timed]*
 > >
 > > *COM4 input stream opened*
 > >
 > > *[2007/04/04 10:40:35]*
 > >
 > > 
*7e42007d5d1d840101009101710031037d5d023003007964 
 > > [40]*

 > >
 > >
 > > CRC = 0x6479 (last bytes)
 > >
 > > i woul like to know how i could use the CRC to check the 
integrity of

 > > the transmitted packet.
 > > and which byte of the packet are taking in acount to compute the 
CRC.

 > >
 > > thanx for your help
 > >
 > >
 >  > 

 > > Invite your mail contacts to join your friends list with Windows 
Live

 > > Spaces. It's easy! Try it!
 > > 
<http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us> 


 > >
 > >
 >  > 


 > >
 > > ___
 > > Tinyos-help mailing list
 > > Tinyos-help@Millennium.Berkeley.EDU
 > > 
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help 





Get news, entertainment and everything you care about at Live.com. 
Check it out! <http://www.live.com/getstarted.aspx >





___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


Re: [Tinyos-help] CRC checking

2007-04-09 Thread Sankar Gorthi

Yes. My mistake.

We would want to make sure the CRC bytes don't have the 7E or 7D bytes. The 
corrected procedure would be as here:


1. create the message packet including everything but the Sync bytes (7E)
2. run the CRC algorithm on the escaped data packet
3. attach the CRC in little endian format (lower byte first)
4. escape the bytes corresponding to 7D, or 7E
5. attach the sync bytes
6. Send.

Sankar.

- Original Message - 
From: "Michael Schippling" <[EMAIL PROTECTED]>

To: "Sankar Gorthi" <[EMAIL PROTECTED]>
Cc: 
Sent: Monday, April 09, 2007 2:56 PM
Subject: Re: [Tinyos-help] CRC checking



you'll want to double check the inclusion of escape bytes,
I think CRC happens _before_ escape...
MS


Sankar Gorthi wrote:
When we were calculating the CRC algorithm using LabVIEW, we did the 
following:


1. create the message packet including everything but the Sync bytes (7E)
2. escape the bytes corresponding to 7D, or 7E
3. run the CRC algorithm on the escaped data packet
4. attach the CRC in little endian format (lower byte first)
5. attach the sync bytes
6. Send.

I hope I got that right.

Sankar.

- Original Message - From: "Michael Schippling" 
<[EMAIL PROTECTED]>

To: "jurin dan" <[EMAIL PROTECTED]>
Cc: "tinyos-help@Millennium.Berkeley.EDU" 


Sent: Monday, April 09, 2007 12:13 PM
Subject: Re: [Tinyos-help] CRC checking



I thing that's in the octavetech page, but I believe it is all bytes
including header, before escapes are applied.
I'm not sure but I think the pre-amble 7E 4x is not included.

MS

jurin dan wrote:


thanks a lot for your reply.
 just one more thing. within the raw data packet, which byte do i use 
to compute the CRC.

is it all byte or only TOS_MSG byte.
 


 > Date: Sun, 8 Apr 2007 17:22:29 -0600
 > From: [EMAIL PROTECTED]
 > To: [EMAIL PROTECTED]
 > CC: tinyos-help@Millennium.Berkeley.EDU
 > Subject: Re: [Tinyos-help] CRC checking
 >
 > This site describes the message format and CRC calculation:
 > 
http://www.octavetech.com/pubs/TB5-01%20Deciphering%20TinyOS%20Serial%20Packets.pdf

 >
 > There's also code in TOS (well...duh) and the java tools which
 > does the CRC. I know one is called crc.java
 >
 > MS
 >
 > jurin dan wrote:
 > >
 > > hi,
 > >
 > > i have the raw data packet below receive with xlisten app:
 > >
 > >
 > > *$ xlisten -r -b=mica2 -s=COM4 -t*
 > >
 > > *xlisten Ver:$Id: xlisten.c,v 1.2 2005/06/21 01:36:06 pipeng Exp 
$*

 > >
 > > *Using params: [baud=0x1001] [raw] [timed]*
 > >
 > > *COM4 input stream opened*
 > >
 > > *[2007/04/04 10:40:35]*
 > >
 > > 
*7e42007d5d1d840101009101710031037d5d023003007964 
 > > [40]*

 > >
 > >
 > > CRC = 0x6479 (last bytes)
 > >
 > > i woul like to know how i could use the CRC to check the integrity 
of

 > > the transmitted packet.
 > > and which byte of the packet are taking in acount to compute the 
CRC.

 > >
 > > thanx for your help
 > >
 > >
 > 
 > 
 > > Invite your mail contacts to join your friends list with Windows 
Live

 > > Spaces. It's easy! Try it!
 > > 
<http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us>

 > >
 > >
 > 
 > 

 > >
 > > ___
 > > Tinyos-help mailing list
 > > Tinyos-help@Millennium.Berkeley.EDU
 > > 
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help




Get news, entertainment and everything you care about at Live.com. 
Check it out! <http://www.live.com/getstarted.aspx >





___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help 


___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


Re: [Tinyos-help] CRC checking

2007-04-09 Thread Ben Buckner
The way my code calculates it is to concatenate the packet type byte and the
payload (TOS_Msg). Then I CRC that all together, append the CRC (low byte
first), and run the escaper on it all (don't forget to catch both 7Es and
7Ds). Then I prepend and append the 7E synch bytes. Seems to work. I'm not
sure why the CRC is part of TOS_Msg, since it seems like it functionally
belongs to the raw packet layer, but that's the way it is I guess. The
Octavetech doc notes this peculiarity as well. 

To test, you can try to CRC the example packet in the Octavetech doc and see
if you get the same result.

Regards,
Ben Buckner

-Original Message-

> I thing that's in the octavetech page, but I believe it is all bytes
> including header, before escapes are applied.
> I'm not sure but I think the pre-amble 7E 4x is not included.
>
> MS
>
> jurin dan wrote:
>> 
>> thanks a lot for your reply.
>>  
>> just one more thing. within the raw data packet, which byte do i use to 
>> compute the CRC.
>> is it all byte or only TOS_MSG byte.
  


___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


Re: [Tinyos-help] CRC checking

2007-04-09 Thread Michael Schippling

Sounds right... however...
I've not seen an exposition of what happens when the CRC has a 7{e,d}...
Logically your algorithm works, but in practice we'd have to reverse
engineer the TOS code...

The CRC is part of the T_M packet since data[] is encapsulated, and it's
at the end so some(unspecified)one _could_ do a fully serial packet
generation, the execution of which I have never seen.

MS

Ben Buckner wrote:

The way my code calculates it is to concatenate the packet type byte and the
payload (TOS_Msg). Then I CRC that all together, append the CRC (low byte
first), and run the escaper on it all (don't forget to catch both 7Es and
7Ds). Then I prepend and append the 7E synch bytes. Seems to work. I'm not
sure why the CRC is part of TOS_Msg, since it seems like it functionally
belongs to the raw packet layer, but that's the way it is I guess. The
Octavetech doc notes this peculiarity as well. 


To test, you can try to CRC the example packet in the Octavetech doc and see
if you get the same result.

Regards,
Ben Buckner

-Original Message-


I thing that's in the octavetech page, but I believe it is all bytes
including header, before escapes are applied.
I'm not sure but I think the pre-amble 7E 4x is not included.

MS

jurin dan wrote:

thanks a lot for your reply.
 
just one more thing. within the raw data packet, which byte do i use to 
compute the CRC.

is it all byte or only TOS_MSG byte.
  



___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


RE: [Tinyos-help] CRC checking

2007-04-10 Thread Ben Buckner
I learned about the CRC escaping for sure by experience, like every once in
a while I would get a packet with the CRC escaped, which caused occasional
errors if I didn't unescape it. Logically, you would have to escape anything
between the framing bytes or else it would have the potential to mess up the
framing logic, but you never know how logically the actual code has been
implemented.

Ben

-Original Message-
From: Michael Schippling [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 09, 2007 10:16 PM
To: Ben Buckner
Cc: tinyos-help@Millennium.Berkeley.EDU
Subject: Re: [Tinyos-help] CRC checking

Sounds right... however...
I've not seen an exposition of what happens when the CRC has a 7{e,d}...
Logically your algorithm works, but in practice we'd have to reverse
engineer the TOS code...

The CRC is part of the T_M packet since data[] is encapsulated, and it's
at the end so some(unspecified)one _could_ do a fully serial packet
generation, the execution of which I have never seen.

MS

Ben Buckner wrote:
> The way my code calculates it is to concatenate the packet type byte and
the
> payload (TOS_Msg). Then I CRC that all together, append the CRC (low byte
> first), and run the escaper on it all (don't forget to catch both 7Es and
> 7Ds). Then I prepend and append the 7E synch bytes. Seems to work. I'm not
> sure why the CRC is part of TOS_Msg, since it seems like it functionally
> belongs to the raw packet layer, but that's the way it is I guess. The
> Octavetech doc notes this peculiarity as well. 
> 
> To test, you can try to CRC the example packet in the Octavetech doc and
see
> if you get the same result.
> 
> Regards,
> Ben Buckner
> 
> -Original Message-
> 
>> I thing that's in the octavetech page, but I believe it is all bytes
>> including header, before escapes are applied.
>> I'm not sure but I think the pre-amble 7E 4x is not included.
>>
>> MS
>>
>> jurin dan wrote:
>>> thanks a lot for your reply.
>>>  
>>> just one more thing. within the raw data packet, which byte do i use to 
>>> compute the CRC.
>>> is it all byte or only TOS_MSG byte.
>   
> 
> 
> ___
> Tinyos-help mailing list
> Tinyos-help@Millennium.Berkeley.EDU
> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


Re: [Tinyos-help] CRC checking

2007-04-10 Thread Ben Buckner

> Yes. My mistake.
>
> We would want to make sure the CRC bytes don't have the 7E or 7D bytes. >
The 
> corrected procedure would be as here:
>
> 1. create the message packet including everything but the Sync bytes (7E)
> 2. run the CRC algorithm on the escaped data packet
> 3. attach the CRC in little endian format (lower byte first)
> 4. escape the bytes corresponding to 7D, or 7E
> 5. attach the sync bytes
> 6. Send.
>
> Sankar.

Hmm... you still CRCed the escaped data in #2 - every byte has to be CRCed
before escaping. I was looking at my code yesterday when I posted, and it
definitely CRCs unescaped data. I think the idea is that the TOS_Msg is
supposed to be a higher layer than the "raw packet" frame, and the CRC is
nominally part of that layer so it shouldn't care what is in the raw packet
(except for that pesky packet type & ACK prefix, it seems). The relevant TOS
code (in TOS 1.11, which I'm using) appears to be in tos\system\FramerM in
ByteComm.rxByteReady()

case RXSTATE_ESC:
  if (data == HDLC_FLAG_BYTE) {
// Error case, fail and resync
gRxByteCnt = gRxRunningCRC = 0;
gMsgRcvTbl[gRxHeadIndex].Length = 0;
gMsgRcvTbl[gRxHeadIndex].Token = 0;
gRxState = RXSTATE_NOSYNC;
  }
  else {
data = data ^ 0x20;  
gpRxBuf[gRxByteCnt] = data; // unescape - BB
if (gRxByteCnt >= 2) { // CRC if we're in the TOS_MSG pkt - BB

  gRxRunningCRC = crcByte(gRxRunningCRC,gpRxBuf[(gRxByteCnt-2)]);
}
gRxByteCnt++;
gRxState = RXSTATE_INFO;
  }
  break;

Note that the receiver unescapes before doing the CRC.
And the transmission:

case TXSTATE_INFO:
  nextByte = gpTxBuf[gTxByteCnt];
  
  gTxRunningCRC = crcByte(gTxRunningCRC,nextByte); // CRC- BB
  gTxByteCnt++;
  if (gTxByteCnt >= gTxLength) {
gTxState = TXSTATE_FCS1;
  }
  
  TxResult = TxArbitraryByte(nextByte); // now escape and Xmit - BB
  break;

Where the TxArbitraryByte function does the escaping:

  result_t TxArbitraryByte(uint8_t inByte) {
if ((inByte == HDLC_FLAG_BYTE) || (inByte == HDLC_CTLESC_BYTE)) {
  atomic {
gPrevTxState = gTxState;
gTxState = TXSTATE_ESC;
gTxEscByte = inByte;
  }
  inByte = HDLC_CTLESC_BYTE;
}

Ben 

--




___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


Re: [Tinyos-help] CRC checking

2007-04-10 Thread Sankar Gorthi
:D I knew someone was going to catch that the moment I read my sent mails 
list. I ought to spend more time rooting out bugs in my emails, or stop 
worrying about sending out errata for emails.


Step 2 ought to have been:
2. Run the CRC algorithm on the raw data packet

Sankar.

- Original Message - 
From: "Ben Buckner" <[EMAIL PROTECTED]>

To: 
Sent: Tuesday, April 10, 2007 10:55 AM
Subject: Re: [Tinyos-help] CRC checking





Yes. My mistake.

We would want to make sure the CRC bytes don't have the 7E or 7D bytes. >

The

corrected procedure would be as here:

1. create the message packet including everything but the Sync bytes (7E)
2. run the CRC algorithm on the escaped data packet
3. attach the CRC in little endian format (lower byte first)
4. escape the bytes corresponding to 7D, or 7E
5. attach the sync bytes
6. Send.

Sankar.


Hmm... you still CRCed the escaped data in #2 - every byte has to be CRCed
before escaping. I was looking at my code yesterday when I posted, and it
definitely CRCs unescaped data. I think the idea is that the TOS_Msg is
supposed to be a higher layer than the "raw packet" frame, and the CRC is
nominally part of that layer so it shouldn't care what is in the raw 
packet
(except for that pesky packet type & ACK prefix, it seems). The relevant 
TOS

code (in TOS 1.11, which I'm using) appears to be in tos\system\FramerM in
ByteComm.rxByteReady()

   case RXSTATE_ESC:
 if (data == HDLC_FLAG_BYTE) {
// Error case, fail and resync
gRxByteCnt = gRxRunningCRC = 0;
gMsgRcvTbl[gRxHeadIndex].Length = 0;
gMsgRcvTbl[gRxHeadIndex].Token = 0;
gRxState = RXSTATE_NOSYNC;
 }
 else {
data = data ^ 0x20;
   gpRxBuf[gRxByteCnt] = data; // unescape - BB
if (gRxByteCnt >= 2) { // CRC if we're in the TOS_MSG pkt - BB

  gRxRunningCRC = crcByte(gRxRunningCRC,gpRxBuf[(gRxByteCnt-2)]);
}
gRxByteCnt++;
gRxState = RXSTATE_INFO;
 }
 break;

Note that the receiver unescapes before doing the CRC.
And the transmission:

   case TXSTATE_INFO:
 nextByte = gpTxBuf[gTxByteCnt];

 gTxRunningCRC = crcByte(gTxRunningCRC,nextByte); // CRC- BB
 gTxByteCnt++;
 if (gTxByteCnt >= gTxLength) {
gTxState = TXSTATE_FCS1;
 }

 TxResult = TxArbitraryByte(nextByte); // now escape and Xmit - BB
 break;

Where the TxArbitraryByte function does the escaping:

 result_t TxArbitraryByte(uint8_t inByte) {
   if ((inByte == HDLC_FLAG_BYTE) || (inByte == HDLC_CTLESC_BYTE)) {
 atomic {
   gPrevTxState = gTxState;
   gTxState = TXSTATE_ESC;
   gTxEscByte = inByte;
 }
 inByte = HDLC_CTLESC_BYTE;
   }

Ben

--








___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help