⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fec_test.c

📁 MANTIS是由科罗拉多大学开发的传感器网络嵌入式操作系统。 这是mantis的0.9.5版本的源码。
💻 C
字号:
//  This file is part of MANTIS OS, Operating System//  See http://mantis.cs.colorado.edu/////  Copyright (C) 2003,2004,2005 University of Colorado, Boulder////  This program is free software; you can redistribute it and/or//  modify it under the terms of the mos license (see file LICENSE)#include "mos.h"#include "msched.h"#include <string.h>#ifndef PLATFORM_LINUX#include "command_daemon.h"#else#include <stdlib.h>#endif#include "printf.h"#include "fec.h"#define ENCODE_TEXT "Nervously I loaded the twin ducks aboard the revolving platform."char msg[sizeof (ENCODE_TEXT)];char text [] = ENCODE_TEXT;uint8_t parity_bytes[MAXIMUM_IMPLEMENTED_PARITY_BYTES];//unsigned char codeword[256];static void process_decode (uint8_t return_val){   if (return_val != FEC_NO_ERRORS) {      printf ("Message had errors, ");      if (return_val == FEC_UNCORRECTABLE_ERRORS)	 printf ("not correctable\n");      else	 printf ("correctable\n");   }}void start (void){   fec_init (8);   strcpy (msg, text);   fec_encode ((uint8_t *)msg, sizeof (text), parity_bytes);   msg[12] = 169;   msg[1] = 170;   msg[24] = 171;   parity_bytes[2] = 171;   printf ("encoded data is \"%s\"\n", msg);   //strcpy (&msg[sizeof (text)], parity_bytes);   process_decode (fec_decode ((uint8_t *)msg, sizeof (text), parity_bytes));   printf ("corrected: \"%s\"\n", msg);   fec_init (4);   fec_encode ((uint8_t *)msg, sizeof (text), parity_bytes);   msg[23] = 1;   msg[55] = 111;   printf ("encoded data is \"%s\"\n", msg);   //strcpy (&msg[sizeof (text)], parity_bytes);   process_decode (fec_decode ((uint8_t *)msg, sizeof (text), parity_bytes));   printf ("corrected: \"%s\"\n", msg);   fec_init (2);   fec_encode ((uint8_t *)msg, sizeof (text), parity_bytes);   msg[55] = 111;   printf ("encoded data is \"%s\"\n", msg);   //strcpy (&msg[sizeof(text)], parity_bytes);   process_decode (fec_decode ((uint8_t *)msg, sizeof (text), parity_bytes));   printf ("corrected: \"%s\"\n", msg);#ifndef PLATFORM_LINUX   mos_thread_new (mos_command_daemon, MOS_COMMANDER_STACK_SIZE,		   PRIORITY_NORMAL);#else   exit (0);#endif}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -