Esempio n. 1
0
int main()
{
	char test;
	char cs;
	char pkt[83];
	char print[] = "Sixteen LCD char";
	char aorp;
	double height;
	struct packet packet_GGA;
	int temp;
	int time[3]      = {0, 0, 0};
	int latitude[3]  = {0, 0, 0};
	int longitude[3] = {0, 0, 0};

	while(1){
		test=getchar();																/*Gets first character from serial stream             */

		*LEDs = *Switches;
		temp  = *LEDs;

		if(checksum(test,cs,pkt)){													/*Pipes all the fun stuff to checksum and parse f'ns  */
			parse_GGA(pkt, &packet_GGA);												/*See gpsparse.h library for full view of functions   */
			temp = (temp & 0x01);
			if (temp == 1){
				sprintf(print, "Lat:%s%c", packet_GGA.latitude, packet_GGA.ns[0]);
				WriteLCD(print);
				sprintf(print, "Lon:%s%c", packet_GGA.longitude, packet_GGA.ew[0]);
				WriteLCD(print);
			};
			if (temp == 0){
				aorp = GMT_to_MST(time, packet_GGA.time);
				sprintf(print, "Time: %d:%02d:%02d%cM", time[0], time[1], time[2], aorp);
				WriteLCD(print);
				height = m_to_ft(packet_GGA.ant_ht);
				sprintf(print, "Elev: %5.2f ft", height);
				WriteLCD(print);
			};
			lat_to_deg(packet_GGA.latitude, latitude);
			long_to_deg(packet_GGA.longitude, longitude);
			printf("Latitude :  %d deg, %d.%05d min\n", latitude[0], latitude[1], latitude[2]);
			printf("Longitude: %d deg, %d.%05d min\n", longitude[0], longitude[1], longitude[2]);
		}
	};
	return 0;
}
Esempio n. 2
0
floating_pointer_struct_t *
scan_for_floating_ptr_struct(uintptr_t addr, uint32_t length)
{
   floating_pointer_struct_t *fp;
   uintptr_t end = addr + length;


   fp = (floating_pointer_struct_t*)addr;
   while ((uintptr_t)fp < end) {
      if (fp->signature == FPSignature) {
	 if (fp->length == 1 && checksum((uint8_t*)fp, 16) == 0) {
	    return fp;
	 } 
      }
      fp++;
   }
   return NULL;
}
Esempio n. 3
0
File: ant.c Progetto: asm/avr_ant
void assign_channel_id(uint8_t type)
{
    uint8_t buf[7];

    buf[0] = MESG_TX_SYNC;           // SYNC Byte
    buf[1] = 0x03;                   // Length Byte
    buf[2] = MESG_ASSIGN_CHANNEL_ID; // ID Byte
    buf[3] = CHAN0;                  // Channel
    buf[4] = type;                   // Type
    buf[5] = NET0;                   // Network
    buf[6] = checksum(buf, 6);

    send_to_ant(buf, 7);

    printf("MESG_ASSIGN_CHANNEL_ID sent\n");

    ant_handle_msg();
}
Esempio n. 4
0
void read_message()
{
     addr_len = sizeof(remote_address)/sizeof(char);
     bytes_read = recvfrom( socket_descriptor,(void *)&pacchetto,
                            sizeof(pacchetto)/sizeof(char),0,
                            (struct sockaddr *)&remote_address, &addr_len );

     if ( bytes_read != -1 ) {
         if ( ( pacchetto.int_versione != 2 )
	           && ( checksum( pacchetto.messaggio,100)!= pacchetto.ulint_crc )
	           && ( bytes_read != (sizeof(pacchetto)/sizeof(char)) )
	      ) delete_message();
     	   else {
	           pacchetto.messaggio[MAXLEN_MSG-1] = 0x00;
		       pacchetto.nome[MAXLEN_USRNAME-1] = 0x00;
		 }
	 } else { printf("(!) recvfrom error\n"); }
}
Esempio n. 5
0
std::string to_string(const sentence & s)
{
	std::string result;
	result.reserve(sentence::max_length);
	result += s.get_start_token();
	result += s.talker();
	result += s.tag();
	for (auto const & data : s.get_data()) {
		result += ",";
		result += data;
	}
	result += s.get_end_token();

	char buf[8];
	snprintf(buf, sizeof(buf), "%02X", checksum(result.begin() + 1, result.end() - 1));

	return result + buf;
}
Esempio n. 6
0
File: ant.c Progetto: asm/avr_ant
void set_channel_period(uint16_t period)
{
    uint8_t buf[7];

    buf[0] = MESG_TX_SYNC;                // SYNC Byte
    buf[1] = 0x03;                        // Length Byte
    buf[2] = MESG_CHANNEL_MESG_PERIOD_ID; // ID Byte
    buf[3] = CHAN0;                       // Channel
    buf[4] = period & 255;                // LSB
    buf[5] = period >> 8;                 // MSB
    buf[6] = checksum(buf, 6);

    send_to_ant(buf, 7);

    printf("MESG_CHANNEL_MESG_PERIOD_ID sent\n");

    ant_handle_msg();
}
Esempio n. 7
0
FileReference::FileReference(const openstudio::path& p)
  : m_uuid(createUUID()),
    m_versionUUID(createUUID()),
    m_name(toString(p)),
    m_displayName(toString(p.filename())),
    m_path(completeAndNormalize(p)),
    m_timestampLast(),
    m_checksumCreate(checksum(m_path)),
    m_checksumLast(m_checksumCreate)
{
  try {
    m_fileType = FileReferenceType(getFileExtension(p));
  }
  catch (...) {
    m_fileType = FileReferenceType::Unknown;
  }
  update(openstudio::path());
}
Esempio n. 8
0
bool FileReference::update(const openstudio::path& searchDirectory,bool lastOnly) {
    makePathAbsolute(searchDirectory);
    openstudio::path p = path();
    if (boost::filesystem::exists(p)) {
        QFileInfo fileInfo(toQString(p));
        OS_ASSERT(fileInfo.exists());

        if (!lastOnly) {
            m_timestampCreate = toDateTime(fileInfo.created());
        }

        m_timestampLast = toDateTime(fileInfo.lastModified());
        m_checksumLast = checksum(p);
        m_versionUUID = createUUID();
        return true;
    }
    return false;
}
Esempio n. 9
0
int check_msg(client_t* client, msg_t* msg)
{
    size_t msg_data_len;
    if (msg->zone.clip)
    {
        if (msg->zone.last && (msg_data_length(msg) % client->max_length))
            msg_data_len = msg_data_length(msg) % client->max_length;
        else
            msg_data_len = client->max_length;
    }
    else msg_data_len = msg_data_length(msg);
    if (checksum(msg, sizeof(msg_t) + msg_data_len))
    {
        SYSLOG(LOG_ERR, "Invalid msg");
        return 0;
    }
    return 1;
}
Esempio n. 10
0
unsigned int SONAR::getDist() {
	debug();
	
#if defined(BOARD_maple) || defined(BOARD_maple_native) || defined(BOARD_maple_mini)
	Serial.flush();
#endif

	sendCmd(_distCmd,sizeof(_distCmd));
	delay(1);
	recvDat(distDatSize);
	#ifdef DEBUG
		showDat(distDatSize);
	#endif
	
	if(checksum(distDatSize)==0) return (_recvBuf[5]<<8)+_recvBuf[6];

	return 0xffff;	// not available distance
}
Esempio n. 11
0
void roomba_t::update()
{
	uint8_t data;

	while(serial_m->available()>0 && serial_m->
	#ifdef __AVR
		readBytes((char *)&data,1)==1
	#else
		read(&data,1)==1
	#endif
		)
	{
		if(serial_state_m==HEADER&&data==ROOMBA_PACKET_HEADER)
		{
			serial_state_m=SIZE;
		}
		else if(serial_state_m==SIZE)
		{
			serial_size_m=data;
			serial_buffer_m=(uint8_t*)malloc(serial_size_m);
			serial_state_m=DATA;
		}
		else if(serial_state_m==DATA)
		{
			serial_buffer_m[serial_pointer_m++]=data;

			if(serial_pointer_m>=serial_size_m)
				serial_state_m=CHECKSUM;
		}
		else if(serial_state_m==CHECKSUM)
		{
			if(checksum(ROOMBA_PACKET_HEADER,serial_size_m,serial_buffer_m,data))
			{
				parse_sensor_packet_m();
				dump_sensors();
			}

			serial_size_m=0;
			free(serial_buffer_m);
			serial_pointer_m=0;
			serial_state_m=HEADER;
		}
	}
}
Esempio n. 12
0
static int check_rx(void)
{

    union {
        u16 value;
        struct {
            u8 lsb;
            u8 msb;
        } bytes;
    } chanval;

    if (NRF24L01_ReadReg(NRF24L01_07_STATUS) & BV(NRF24L01_07_RX_DR)) {
        // data received from aircraft
        XN297_ReadPayload(packet, PACKET_SIZE);

        NRF24L01_WriteReg(NRF24L01_07_STATUS, 255);

        NRF24L01_FlushRx();
        // decode data , check sum is ok as well, since there is no crc
        if (packet[0] == 0x85 && packet[14] == checksum()) {
            // uncompensated battery volts*100
            chanval.bytes.msb = packet[3] & 0x7;
            u8 flags = packet[3] >> 3;
            chanval.bytes.lsb = packet[4] & 0xff;
            Telemetry.value[TELEM_DSM_FLOG_VOLT1] = chanval.value;
            TELEMETRY_SetUpdated(TELEM_DSM_FLOG_VOLT1);

            // compensated battery volts*100
            chanval.bytes.msb = packet[5] & 0x7;
            chanval.bytes.lsb = packet[6] & 0xff;
            Telemetry.value[TELEM_DSM_FLOG_VOLT2] = chanval.value;
            TELEMETRY_SetUpdated(TELEM_DSM_FLOG_VOLT2);

            // reception in packets / sec , multiplied by 2
            Telemetry.value[TELEM_DSM_FLOG_HOLDS] = packet[7] * 2;
            TELEMETRY_SetUpdated(TELEM_DSM_FLOG_HOLDS);

            // battery low flag
            Telemetry.value[TELEM_DSM_FLOG_FADESL] = (flags & 1) ? 100 : 0;
            TELEMETRY_SetUpdated(TELEM_DSM_FLOG_FADESL);

            telemetry_count++;
            return 1;
        }                       // end tel received
Esempio n. 13
0
ssize_t read_msg_t(client_t* client, msg_t** msg, double timeout)
{
    if (qtun->use_udp)
    {
        *msg = pool_room_realloc(&qtun->pool, RECV_ROOM_IDX, qtun->recv_buffer_len);
        return read_t(client, *msg, qtun->recv_buffer_len, timeout);
    }
    else
    {
        ssize_t rc;
        size_t len;

        *msg = pool_room_realloc(&qtun->pool, RECV_ROOM_IDX, sizeof(msg_t));
        if (*msg == NULL) return -2;
        rc = read_t(client, *msg, sizeof(**msg), timeout);
        if (rc <= 0)
        {
            pool_room_free(&qtun->pool, RECV_ROOM_IDX);
            *msg = NULL;
            return rc;
        }
        len = msg_data_length(*msg);
        *msg = pool_room_realloc(&qtun->pool, RECV_ROOM_IDX, sizeof(msg_t) + len);
        if (*msg == NULL) return -2;
        rc = read_t(client, (*msg)->data, len, timeout);
        if (rc <= 0 && len)
        {
            pool_room_free(&qtun->pool, RECV_ROOM_IDX);
            *msg = NULL;
            return rc;
        }

        if (checksum(*msg, sizeof(msg_t) + len))
        {
            SYSLOG(LOG_ERR, "Invalid msg");
            pool_room_free(&qtun->pool, RECV_ROOM_IDX);
            *msg = NULL;
            return -2;
        }

        SYSLOG(LOG_INFO, "read msg length: %lu", (unsigned long)len);
        return rc + sizeof(msg_t);
    }
}
Esempio n. 14
0
int fix_message_parse(struct fix_message *self, struct fix_dialect *dialect, struct buffer *buffer, unsigned long flags)
{
    const char *start;
    int ret;

    self->head_buf = buffer;

    TRACE(LIBTRADING_FIX_MESSAGE_PARSE(self, dialect, buffer));
retry:
    ret = FIX_MSG_STATE_PARTIAL;

    start	= buffer_start(buffer);

    if (!buffer_size(buffer))
        goto fail;

    ret = first_three_fields(self, flags);
    if (ret)
        goto fail;

    ret = checksum(self, buffer, flags);
    if (ret)
        goto fail;

    rest_of_message(self, dialect, buffer);

    self->iov[0].iov_base	= (void *)start;
    self->iov[0].iov_len 	= buffer_start(buffer) - start;

    TRACE(LIBTRADING_FIX_MESSAGE_PARSE_RET());

    return 0;

fail:
    if (ret != FIX_MSG_STATE_PARTIAL)
        goto retry;

    buffer_advance(buffer, start - buffer_start(buffer));

    TRACE(LIBTRADING_FIX_MESSAGE_PARSE_ERR());

    return -1;
}
Byte* serializeFrame(int i) {
	int offset=0;
	Byte* serializedFrame[15+DATAMAX];
	
	memcpy(serializedFrame + offset, &frameStorage[i].soh, sizeof(frameStorage[i].soh));
	offset+=sizeof(frameStorage[i].soh);
	memcpy(serializedFrame + offset, &frameStorage[i].frameno, sizeof(frameStorage[i].frameno));
	offset+=sizeof(frameStorage[i].frameno);
	memcpy(serializedFrame + offset, &frameStorage[i].stx, sizeof(frameStorage[i].stx));
	offset+=sizeof(frameStorage[i].stx);
	memcpy(serializedFrame + offset, frameStorage[i].data, strlen(frameStorage[i].data));
	offset+=strlen(frameStorage[i].data);
	memcpy(serializedFrame + offset, &frameStorage[i].etx, sizeof(frameStorage[i].etx));
	offset+=sizeof(frameStorage[i].etx);
	frameStorage[i].checksum = checksum(serializedFrame,offset);
	memcpy(serializedFrame + offset, &frameStorage[i].checksum, sizeof(frameStorage[i].checksum));
	offset+=sizeof(frameStorage[i].checksum);
	return serializedFrame;
}
Esempio n. 16
0
void
convex::grow_extent( extent& world)
{
	if (degenerate())
		return;

	long check = checksum();
	if (check != last_checksum) {
		recalc();
	}
	assert( hull.size() != 0);

	for (std::vector<face>::const_iterator f = hull.begin(); f != hull.end(); ++f) {
		world.add_point( f->corner[0]);
		world.add_point( f->corner[1]);
		world.add_point( f->corner[2]);
	}
	world.add_body();
}
Esempio n. 17
0
void OfflineInit(void)
{
	
	pmcu_cfg=(const MCU_CFG*)MCU_CFG_BASE;
	if((checksum((u8 *)pmcu_cfg,sizeof(MCU_CFG)))||(pmcu_cfg->flag != FISH_MAN))
	{
		EarseAndResetAll();
	}
	else
	{
		memcpy((u8 *)&mcu_scfg,(const u8 *)pmcu_cfg,sizeof(MCU_CFG));
	}
	//always set false at POR or other reset
	pwd_authed=FALSE;
	//set offline download result LED off
	GPIO_SetBits(GPIOE, GPIO_Pin_5);
	//for test
	//mcu_scfg.flash_offset=0x8040000;
}
Esempio n. 18
0
File: comm.c Progetto: horazont/hint
bool _comm_send(int fd, const struct msg_header_t *hdr, const uint8_t *payload)
{
    enum comm_status_t result = COMM_ERR_NONE;
    msg_checksum_t cs = checksum(payload, hdr->payload_length);

    result = _comm_write_checked(fd, hdr, sizeof(struct msg_header_t));
    if (result != COMM_ERR_NONE) {
        return result;
    }
    result = _comm_write_checked(fd, payload, hdr->payload_length);
    if (result != COMM_ERR_NONE) {
        return result;
    }
    result = _comm_write_checked(fd, &cs, sizeof(msg_checksum_t));
    if (result != COMM_ERR_NONE) {
        return result;
    }
    return true;
}
Esempio n. 19
0
static void writePacket(int fd, short cmd, void *data, size_t length) {
    char *buffer = malloc(PACKET_SIZE(length));
    //memset(buffer, 0, PACKET_SIZE(length));
    CmdPacket *packet = (CmdPacket *) buffer;
    packet->w02 = 2;
    packet->cmd = cmd;
    packet->dataSize = length;
    memcpy(buffer + CMD_PACKET_SIZE, data, length);
    CmdPacketEnd *end = (CmdPacketEnd *) (buffer + CMD_PACKET_SIZE + length);
    end->checksum = checksum(packet, data);
    end->w03 = 3;

    LOG(LOGLEVEL_TRACE, "Writing packet:\n");
    LOGDO(LOGLEVEL_TRACE, printBuffer(buffer, PACKET_SIZE(length)));

    write(fd, buffer, PACKET_SIZE(length));

    free(buffer);
}
Esempio n. 20
0
/* decode ublox raw message --------------------------------------------------*/
static int decode_ubx(raw_t *raw)
{
    int type=(U1(raw->buff+2)<<8)+U1(raw->buff+3);
    
    trace(3,"decode_ubx: type=%04x len=%d\n",type,raw->len);
    
    /* checksum */
    if (!checksum(raw->buff,raw->len)) {
        trace(2,"ubx checksum error: type=%04x len=%d\n",type,raw->len);
        return -1;
    }
    sprintf(raw->msgtype,"UBLOX: type=%2d len=%3d",type,raw->len);
    
    switch (type) {
        case ID_RXMRAW : return decode_rxmraw(raw);
        case ID_RXMSFRB: return decode_rxmsfrb(raw);
    }
    return 0;
}
Esempio n. 21
0
static struct acpi_rsdp_descriptor *acpi_scan_for_rsdp(u8 *begin, u32 length)
{
	struct acpi_rsdp_descriptor *rsdp;
	u8 *i, *end = begin + length;
	/* Search from given start address for the requested length */
	for (i = begin; i < end; i += ACPI_RSDP_SCAN_STEP) {
		/* The signature and checksum must both be correct */
		if (memcmp((char *)i, "RSD PTR ", 8)) continue;
		rsdp = (struct acpi_rsdp_descriptor *)i;
		/* Signature matches, check the appropriate checksum */
		if (!checksum((u8 *) rsdp, (rsdp->revision < 2) ?
			      ACPI_RSDP_CHECKSUM_LENGTH :
			      ACPI_RSDP_XCHECKSUM_LENGTH))
			/* Checksum valid, we have found a valid RSDP */
			return rsdp;
	}
	/* Searched entire block, no RSDP was found */
	return 0;
}
Esempio n. 22
0
void group_and_source_specific_query(int sockfd, struct in_addr saddr,
                                     struct in_addr daddr, struct in_addr group,
                                     struct in_addr *sources, int num_sources,
                                     int max_resp_time)
{
    int len = sizeof(struct iphdr) + sizeof(struct ipopts)
              + sizeof(struct igmpv3_query) + num_sources*sizeof(__be32);

    unsigned char *buffer = malloc(len);
    if (buffer == NULL) {
        perror("malloc()");
        exit(EXIT_FAILURE);
    }

    struct iphdr *ip_header = (struct iphdr *) buffer;

    struct ipopts *ip_options = (struct ipopts *)(buffer + sizeof(struct iphdr));

    struct igmpv3_query *igmp_header;
    igmp_header = (struct igmpv3_query *) (buffer + sizeof(struct iphdr)
                                           + sizeof(struct ipopts));

    ip_header_init(ip_header, saddr, daddr);
    ip_options_init(ip_options);

    igmp_header->type = IGMP_HOST_MEMBERSHIP_QUERY;
    igmp_header->code = max_resp_time;

    igmp_header->group = group.s_addr;

    int i;
    for (i = 0; i < num_sources; i++)
        igmp_header->srcs[i] = sources[i].s_addr;

    igmp_header->csum = 0;
    igmp_header->csum = checksum((unsigned short *) igmp_header,
                                 sizeof(struct igmpv3_query) +
                                 num_sources*sizeof(__be32));

    send_ip_frame(sockfd, daddr, buffer, len);
    free(buffer);
}
Esempio n. 23
0
int Communication::motorSend(int instruction, int dataLength, byte data[], int id)
{
	byte packet[dataLength+6];
	int i = 0;
	packet[0] = 0xff;
	packet[1] = 0xff;
	packet[2] = id;
	packet[3] = dataLength+2;
	packet[4] = instruction;
	
	for(i=0;i<dataLength;i++)
	packet[5+i]=data[i];
	
	packet[5+dataLength] = checksum(packet);
	
	if(ftdi_write_data(&bodyFTDI, packet, packet[3]+4)>0)
		return EXIT_SUCCESS;
	else 
		return EXIT_FAILURE;
}
Esempio n. 24
0
void InterruptRoutine(unsigned char *Buffer, int BufferSize)
{
    // When one buffer has been filled
    // Print both buffers (sorta echo)
//    int i;
//    for (i = 0; i < BufferSize; i++) {
//        Uart2PrintChar(Buffer[i]);
//    }
//     Set the pointer so we can copy the data in main.
//    bufferPointer = Buffer;

//    CB_WriteMany(&circBuf, fakeInput, 512, true); // fake data
//
//    if (fakeInput[0] == 'D') fakeInput[0] = '!';
//    else fakeInput[0] = fakeInput[0]+1;
    if(checksum(Buffer, 512) != goodSum) {
        FATAL_ERROR();
    }
    CB_WriteMany(&circBuf, Buffer, BufferSize, true); // fail early
}
Esempio n. 25
0
void
prepareboot(void)
{
    // Change TPM phys. presence state befor leaving BIOS
    tpm_prepboot();

    // Run BCVs
    bcv_prepboot();

    // Finalize data structures before boot
    cdrom_prepboot();
    pmm_prepboot();
    malloc_prepboot();
    e820_prepboot();

    HaveRunPost = 2;

    // Setup bios checksum.
    BiosChecksum -= checksum((u8*)BUILD_BIOS_ADDR, BUILD_BIOS_SIZE);
}
Esempio n. 26
0
void Incident::save(TiXmlDocument* xmlDocument)
{
    std::string data;

    // create incident node
    TiXmlElement* incidentElement = new TiXmlElement( "incident" );
    incidentElement->SetAttribute( "name", _name.c_str() );
    incidentElement->SetAttribute( "location", _locationId );

    // create virtues node        
    TiXmlElement* virtuesElement = new TiXmlElement( "virtues" );
    virtuesElement->SetAttribute( "checksum", checksum( &_virtues, sizeof(Virtues) ) );
    encrypt( data, &_virtues, sizeof(Virtues), _name.c_str() );
    virtuesElement->SetAttribute( "data", data.c_str() );
    incidentElement->InsertEndChild( *virtuesElement );
    delete virtuesElement;

    xmlDocument->InsertEndChild( *incidentElement );
    delete incidentElement;
}
Esempio n. 27
0
static int icmp_loopback (ICMP_PKT *icmp, unsigned icmp_len)
{
  if (icmp_len >= sizeof(icmp->echo)    &&
      checksum(icmp,icmp_len) == 0xFFFF &&
      icmp->echo.type == ICMP_ECHO)
  {
    static WORD echo_seq_num = 0;

    icmp->echo.type     = ICMP_ECHOREPLY;
    icmp->echo.sequence = echo_seq_num++;
    icmp->echo.checksum = 0;
    icmp->echo.checksum = ~checksum (icmp, icmp_len);
    STAT (icmpstats.icps_reflect++);
    STAT (icmpstats.icps_outhist[ICMP_ECHOREPLY]++);
    return (icmp_len);
  }
  /* !!to-do: fall-through to another ICMP loopback handler */

  return (0);
}
Esempio n. 28
0
std::string Node::thirdString() const
{
    std::string res = "2 ";
    res += string2string(satelliteNumber(), 5) + " ";
    res += double2string(normalizeAngle(i()), 8, 4, false, false, false) + " ";
    res += double2string(normalizeAngle(Omega()), 8, 4, false, false, false) +
           " ";
    res += double2string(e(), 7, 7, false, true, false) + " ";
    res += double2string(normalizeAngle(omega()), 8, 4, false, false, false) +
           " ";
    res += double2string(normalizeAngle(M()), 8, 4, false, false, false) + " ";
    res += double2string(n(), 11, 8, false, false, false);
    res += int2string(revolutionNumber(), 5, false);

    // Checksum
    int sum = checksum(res);
    res += int2string(sum, 1);

    return res;
}
Esempio n. 29
0
void ICMPv4PacketImpl::initPacket()
{
	if (_seq >= MAX_SEQ_VALUE) resetSequence();

	Header* icp = (Header*) packet(false);
	icp->type     = ECHO_REQUEST;
	icp->code     = 0;
	icp->checksum = 0;
	icp->seq      = ++_seq;
#if defined(POCO_VXWORKS)
	icp->id       = 0;
#else
	icp->id       = static_cast<UInt16>(Poco::Process::id());
#endif

	struct timeval* ptp = (struct timeval *) (icp + 1);
	*ptp = time();

	icp->checksum = checksum((UInt16*) icp, getDataSize() + sizeof(Header));
}
static void test_scalarmult(void) {

    long long i, j;
    unsigned char outpk[BYTES];

    for (i = 0; i < BYTES; ++i) pk[i] = basepoint[i];

    checksum_zero();
    for (i = 0; i < 1080; ++i) {
        pk[31] |= 128;
        if (crypto_scalarmult_curve25519(outpk, skdata[i], pk) != 0) {
            fail_printdata("pk", pk, BYTES);
            fail_printdata("sk", skdata[i], SCALARBYTES);
            fail("crypto_scalarmult_curve25519() failure, please report it !!!!!!!!!");
        }
        checksum(outpk, BYTES);
        for (j = 0; j < BYTES; ++j) pk[j] = outpk[j];
    }
    fail_whenbadchecksum(test_scalarmult_checksum);
}