Hmm...if I were in your situation, my thinking would be along the lines of: "I
need to generate a CRC-16 value for communicating with Poser. In order for Poser
to support this, it must be able to calculate a CRC-16 value. Since the source
code to Poser is available, then I can just snag *its* routine and use it." And
sure enough, there's a Crc.c file that comes with Poser that has the function
you want.

On the other hand, you could probably just skip all that, since I don't think
Poser validates the checksum right now.  So set that field to zero and see what
happens. Eventually I may get around to validating the checksum, but for now I
don't want to make things too difficult for developers in your situation. But
set the checksum to zero!  If I later add checksum support, then I'll only do it
when the checksum field is non-zero.

-- Keith Rollin
-- Palm OS Emulator engineer





"Eric Arseneau" <[EMAIL PROTECTED]> on 10/26/99 11:13:10 PM

Please respond to [EMAIL PROTECTED]

Sent by:  "Eric Arseneau" <[EMAIL PROTECTED]>


To:   "palm-dev-forum @3com.com" <[EMAIL PROTECTED]>, "Emulator-Forum"
      <[EMAIL PROTECTED]>
cc:    (Keith Rollin/HQ/3Com)
Subject:  CRC16




I'm in the middle of building a debugger for my VM and I am starting to use
the interface to the debugger.  The format of the messages back and forth
from POSEr or the device, require a CRC16 checksum.  I've tried to find some
on the net and have had a very difficult time.  I found one, but I can't
seem to make it work.  Now I am not a C programmer so that I may not have
translated the code properly.  Would anyone have any info on how I can
compute this ?  Info a mere mortal could use.

Here is some code I found, but I don't think it works:


#include <stdlib.h>
#include <stdio.h>

unsigned int crc_16_table[16] = {
  0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
  0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400 };

unsigned short int get_crc_16 (int start, char *p, int n) {
  unsigned short int crc = start;
  int r;

  /* while there is more data to process */
  while (n-- > 0) {

    /* compute checksum of lower four bits of *p */
    r = crc_16_table[crc & 0xF];
    crc = (crc >> 4) & 0x0FFF;
    crc = crc ^ r ^ crc_16_table[*p & 0xF];

    /* now compute checksum of upper four bits of *p */
    r = crc_16_table[crc & 0xF];
    crc = (crc >> 4) & 0x0FFF;
    crc = crc ^ r ^ crc_16_table[(*p >> 4) & 0xF];

    /* next... */
    p++;
  }

  return(crc);
}

I can't seem to find tests to see what the result should be.  If anyone has
the source from the Palm ROMs, then maybe it's going to be more
understandble.

Thank you for any help,

-----------------------------
Eric Arseneau ([EMAIL PROTECTED])
Pocket Smalltalk Group
www.PocketSmalltalk.com
Smalltalk-80 for the Palm(R) Computing Platform







Reply via email to