📄 test_6.c
字号:
/* This file is part of MANTIS OS, Operating System for Nymph. See http://mantis.cs.colorado.edu/ Copyright (C) 2003 University of Colorado, Boulder This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License (See http://www.gnu.org/copyleft/gpl.html) along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA, or send email to mantis-users@cs.colorado.edu.*//* Automated test for forward error correction */#include "mos.h"#include "msched.h"#include <string.h>#ifndef PLATFORM_LINUX#include "command_daemon.h"#include "printf.h"#else#include <stdio.h>#include <stdlib.h>#endif#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];thread_t *current_thread;//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"); }}static void test_fec(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); mos_thread_resume(current_thread);}static void fec_test(void){ mos_thread_new (test_fec, 196, PRIORITY_NORMAL); current_thread = mos_thread_current(); mos_thread_suspend(); mos_thread_sleep(10); mos_thread_new (mos_command_daemon, 212, PRIORITY_NORMAL); }void start (void){ mos_thread_new (fec_test, 64, PRIORITY_NORMAL);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -