Rewrite from scratch a TCP/IP stack for mbed. So far the following parts are usable: Drivers: - EMAC driver (from CMSIS 2.0) Protocols: - Ethernet protocol - ARP over ethernet for IPv4 - IPv4 over Ethernet - ICMPv4 over IPv4 - UDPv4 over IPv4 APIs: - Sockets for UDPv4 The structure of this stack is designed to be very modular. Each protocol can register one or more protocol to handle its payload, and in each protocol, an API can be hooked (like Sockets for example). This is an early release.
Debug.cpp
00001 /* 00002 * $Id: Debug.c 26 2011-06-09 10:24:02Z benoit $ 00003 * $Author: benoit $ 00004 * $Date: 2011-06-09 12:24:02 +0200 (jeu., 09 juin 2011) $ 00005 * $Rev: 26 $ 00006 * 00007 * 00008 * 00009 * 00010 * 00011 */ 00012 00013 #include "Debug.h" 00014 00015 00016 Debug_LevelMask_t debug_LevelMask = DEBUG_LEVEL_WARNING | DEBUG_LEVEL_ERROR | DEBUG_LEVEL_PANIC; 00017 Debug_ModuleMask_t debug_ModuleMask = DEBUG_MODULE_ALL; 00018 00019 00020 void Debug_SetMasks(Debug_ModuleMask_t moduleMask, Debug_LevelMask_t levelMask) 00021 { 00022 debug_LevelMask = levelMask; 00023 debug_ModuleMask = moduleMask; 00024 } 00025 00026 const char *Debug_GetText(uint32_t level) 00027 { 00028 char *result; 00029 00030 switch(level) 00031 { 00032 case DEBUG_LEVEL_INFO: 00033 result = "INFO"; 00034 break; 00035 00036 case DEBUG_LEVEL_WARNING: 00037 result = "WARNING"; 00038 break; 00039 00040 case DEBUG_LEVEL_ERROR: 00041 result = "ERROR"; 00042 break; 00043 00044 case DEBUG_LEVEL_PANIC: 00045 result = "PANIC"; 00046 break; 00047 00048 case DEBUG_LEVEL_VERBOSE0: 00049 result = "VERBOSE0"; 00050 break; 00051 00052 case DEBUG_LEVEL_VERBOSE1: 00053 result = "VERBOSE1"; 00054 break; 00055 00056 case DEBUG_LEVEL_VERBOSE2: 00057 result = "VERBOSE2"; 00058 break; 00059 00060 default: 00061 result = "<unknown>"; 00062 break; 00063 } 00064 00065 return result; 00066 } 00067 00068 00069 void Debug_DumpBufferHex(uint8_t *buffer, int32_t length) 00070 { 00071 int32_t i, address, index, tmpIndex; 00072 00073 index = 0; 00074 address = 0; 00075 while(index < length) 00076 { 00077 /* Print buffer relative address */ 00078 DEBUG_RAW_NOCRLF(("%03X ", address)); 00079 00080 /* Print hex bytes */ 00081 for (i = 0; i < DEBUG_BUFFER_DUMP_LINE_LEN; i++) 00082 { 00083 tmpIndex = index + i; 00084 if (tmpIndex < length) 00085 { 00086 DEBUG_RAW_NOCRLF(("%02X ", buffer[tmpIndex])); 00087 } 00088 else 00089 { 00090 DEBUG_RAW_NOCRLF((" ")); 00091 } 00092 } 00093 00094 DEBUG_RAW_NOCRLF((" - ")); 00095 00096 /* Print ascii chars */ 00097 for (i = 0; i < DEBUG_BUFFER_DUMP_LINE_LEN; i++) 00098 { 00099 tmpIndex = index + i; 00100 if (tmpIndex < length) 00101 { 00102 DEBUG_RAW_NOCRLF(("%c", buffer[tmpIndex] >= 32 ? buffer[tmpIndex] : '.')); 00103 } 00104 } 00105 00106 index += DEBUG_BUFFER_DUMP_LINE_LEN; 00107 address += DEBUG_BUFFER_DUMP_LINE_LEN; 00108 00109 DEBUG_RAW_NOCRLF(("\r\n")); 00110 } 00111 00112 } 00113
Generated on Wed Jul 13 2022 06:09:33 by 1.7.2