Merge branch 'bugfix/lwip_compat_headers' into 'master'
lwip: add compatibility headers for sntp.h and esp_ping.h See merge request idf/esp-idf!3231
This commit is contained in:
commit
6baf743212
8 changed files with 37 additions and 16 deletions
|
@ -4,9 +4,6 @@
|
||||||
#if __has_include("soc/soc.h")
|
#if __has_include("soc/soc.h")
|
||||||
#include "soc/soc.h"
|
#include "soc/soc.h"
|
||||||
#endif
|
#endif
|
||||||
#if __has_include("apps/ping/esp_ping.h")
|
|
||||||
#include "apps/ping/esp_ping.h"
|
|
||||||
#endif
|
|
||||||
#if __has_include("esp32/ulp.h")
|
#if __has_include("esp32/ulp.h")
|
||||||
#include "esp32/ulp.h"
|
#include "esp32/ulp.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,6 +25,9 @@
|
||||||
#if __has_include("esp_ota_ops.h")
|
#if __has_include("esp_ota_ops.h")
|
||||||
#include "esp_ota_ops.h"
|
#include "esp_ota_ops.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if __has_include("esp_ping.h")
|
||||||
|
#include "esp_ping.h"
|
||||||
|
#endif
|
||||||
#if __has_include("esp_spi_flash.h")
|
#if __has_include("esp_spi_flash.h")
|
||||||
#include "esp_spi_flash.h"
|
#include "esp_spi_flash.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -420,7 +420,7 @@ static const esp_err_msg_t esp_err_msg_table[] = {
|
||||||
# ifdef ESP_ERR_TCPIP_ADAPTER_DHCP_NOT_STOPPED
|
# ifdef ESP_ERR_TCPIP_ADAPTER_DHCP_NOT_STOPPED
|
||||||
ERR_TBL_IT(ESP_ERR_TCPIP_ADAPTER_DHCP_NOT_STOPPED), /* 20487 0x5007 */
|
ERR_TBL_IT(ESP_ERR_TCPIP_ADAPTER_DHCP_NOT_STOPPED), /* 20487 0x5007 */
|
||||||
# endif
|
# endif
|
||||||
// components/lwip/include/apps/ping/esp_ping.h
|
// components/lwip/include/apps/esp_ping.h
|
||||||
# ifdef ESP_ERR_PING_BASE
|
# ifdef ESP_ERR_PING_BASE
|
||||||
ERR_TBL_IT(ESP_ERR_PING_BASE), /* 24576 0x6000 */
|
ERR_TBL_IT(ESP_ERR_PING_BASE), /* 24576 0x6000 */
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -3,6 +3,7 @@ set(COMPONENT_ADD_INCLUDEDIRS
|
||||||
lwip/src/include
|
lwip/src/include
|
||||||
port/esp32/include
|
port/esp32/include
|
||||||
port/esp32/include/arch
|
port/esp32/include/arch
|
||||||
|
include_compat
|
||||||
)
|
)
|
||||||
|
|
||||||
set(COMPONENT_SRCS "apps/dhcpserver/dhcpserver.c"
|
set(COMPONENT_SRCS "apps/dhcpserver/dhcpserver.c"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "ping/esp_ping.h"
|
#include "esp_ping.h"
|
||||||
|
|
||||||
#include "lwip/ip_addr.h"
|
#include "lwip/ip_addr.h"
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
#endif /* PING_USE_SOCKETS */
|
#endif /* PING_USE_SOCKETS */
|
||||||
|
|
||||||
#ifdef ESP_PING
|
#ifdef ESP_PING
|
||||||
#include "ping/esp_ping.h"
|
#include "esp_ping.h"
|
||||||
#include "lwip/ip_addr.h"
|
#include "lwip/ip_addr.h"
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,8 @@ COMPONENT_ADD_INCLUDEDIRS := \
|
||||||
include/apps \
|
include/apps \
|
||||||
lwip/src/include \
|
lwip/src/include \
|
||||||
port/esp32/include \
|
port/esp32/include \
|
||||||
port/esp32/include/arch
|
port/esp32/include/arch \
|
||||||
|
include_compat
|
||||||
|
|
||||||
COMPONENT_SRCDIRS := \
|
COMPONENT_SRCDIRS := \
|
||||||
apps/dhcpserver \
|
apps/dhcpserver \
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// gen_esp_err_to_name.py: include this as "esp_ping.h" because "components/lwip/include/apps/" is in the compiler path
|
||||||
|
// and not "components/lwip/include"
|
||||||
|
|
||||||
#define ESP_ERR_PING_BASE 0x6000
|
#define ESP_ERR_PING_BASE 0x6000
|
||||||
|
|
||||||
#define ESP_ERR_PING_INVALID_PARAMS ESP_ERR_PING_BASE + 0x01
|
#define ESP_ERR_PING_INVALID_PARAMS ESP_ERR_PING_BASE + 0x01
|
3
components/lwip/include_compat/apps/sntp/sntp.h
Normal file
3
components/lwip/include_compat/apps/sntp/sntp.h
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
#warning "This header file is deprecated, please include lwip/apps/sntp.h instead."
|
||||||
|
#include "lwip/apps/sntp.h"
|
|
@ -57,13 +57,15 @@ class ErrItem(object):
|
||||||
Contains information about the error:
|
Contains information about the error:
|
||||||
- name - error string
|
- name - error string
|
||||||
- file - relative path inside the IDF project to the file which defines this error
|
- file - relative path inside the IDF project to the file which defines this error
|
||||||
|
- include_as - (optional) overwrites the include determined from file
|
||||||
- comment - (optional) comment for the error
|
- comment - (optional) comment for the error
|
||||||
- rel_str - (optional) error string which is a base for the error
|
- rel_str - (optional) error string which is a base for the error
|
||||||
- rel_off - (optional) offset in relation to the base error
|
- rel_off - (optional) offset in relation to the base error
|
||||||
"""
|
"""
|
||||||
def __init__(self, name, file, comment, rel_str = "", rel_off = 0):
|
def __init__(self, name, file, include_as = None, comment = "", rel_str = "", rel_off = 0):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.file = file
|
self.file = file
|
||||||
|
self.include_as = include_as
|
||||||
self.comment = comment
|
self.comment = comment
|
||||||
self.rel_str = rel_str
|
self.rel_str = rel_str
|
||||||
self.rel_off = rel_off
|
self.rel_off = rel_off
|
||||||
|
@ -104,7 +106,7 @@ class InputError(RuntimeError):
|
||||||
def __init__(self, p, e):
|
def __init__(self, p, e):
|
||||||
super(InputError, self).__init__(p + ": " + e)
|
super(InputError, self).__init__(p + ": " + e)
|
||||||
|
|
||||||
def process(line, idf_path):
|
def process(line, idf_path, include_as):
|
||||||
"""
|
"""
|
||||||
Process a line of text from file idf_path (relative to IDF project).
|
Process a line of text from file idf_path (relative to IDF project).
|
||||||
Fills the global list unproc_list and dictionaries err_dict, rev_err_dict
|
Fills the global list unproc_list and dictionaries err_dict, rev_err_dict
|
||||||
|
@ -160,11 +162,11 @@ def process(line, idf_path):
|
||||||
related
|
related
|
||||||
except NameError:
|
except NameError:
|
||||||
# The value of the error is known at this moment because it do not depends on some other BASE error code
|
# The value of the error is known at this moment because it do not depends on some other BASE error code
|
||||||
err_dict[num].append(ErrItem(words[1], idf_path, comment))
|
err_dict[num].append(ErrItem(words[1], idf_path, include_as, comment))
|
||||||
rev_err_dict[words[1]] = num
|
rev_err_dict[words[1]] = num
|
||||||
else:
|
else:
|
||||||
# Store the information available now and compute the error code later
|
# Store the information available now and compute the error code later
|
||||||
unproc_list.append(ErrItem(words[1], idf_path, comment, related, num))
|
unproc_list.append(ErrItem(words[1], idf_path, include_as, comment, related, num))
|
||||||
|
|
||||||
def process_remaining_errors():
|
def process_remaining_errors():
|
||||||
"""
|
"""
|
||||||
|
@ -180,7 +182,7 @@ def process_remaining_errors():
|
||||||
base_num = rev_err_dict[item.rel_str]
|
base_num = rev_err_dict[item.rel_str]
|
||||||
base = err_dict[base_num][0]
|
base = err_dict[base_num][0]
|
||||||
num = base_num + item.rel_off
|
num = base_num + item.rel_off
|
||||||
err_dict[num].append(ErrItem(item.name, item.file, item.comment))
|
err_dict[num].append(ErrItem(item.name, item.file, item.include_as, item.comment))
|
||||||
rev_err_dict[item.name] = num
|
rev_err_dict[item.name] = num
|
||||||
else:
|
else:
|
||||||
print(item.rel_str + " referenced by " + item.name + " in " + item.file + " is unknown")
|
print(item.rel_str + " referenced by " + item.name + " in " + item.file + " is unknown")
|
||||||
|
@ -233,6 +235,9 @@ def generate_c_output(fin, fout):
|
||||||
includes = set()
|
includes = set()
|
||||||
for k in err_dict:
|
for k in err_dict:
|
||||||
for e in err_dict[k]:
|
for e in err_dict[k]:
|
||||||
|
if e.include_as:
|
||||||
|
includes.add(e.include_as)
|
||||||
|
else:
|
||||||
includes.add(path_to_include(e.file))
|
includes.add(path_to_include(e.file))
|
||||||
|
|
||||||
# The order in a set in non-deterministic therefore it could happen that the
|
# The order in a set in non-deterministic therefore it could happen that the
|
||||||
|
@ -308,6 +313,9 @@ def main():
|
||||||
parser.add_argument('--rst_output', help='Generate .rst output and save it into this file')
|
parser.add_argument('--rst_output', help='Generate .rst output and save it into this file')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
include_as_pattern = re.compile(r'\s*//\s*{}: [^"]* "([^"]+)"'.format(os.path.basename(__file__)))
|
||||||
|
define_pattern = re.compile(r'\s*#define\s+(ESP_ERR_|ESP_OK|ESP_FAIL)')
|
||||||
|
|
||||||
for root, dirnames, filenames in os.walk(idf_path):
|
for root, dirnames, filenames in os.walk(idf_path):
|
||||||
for filename in fnmatch.filter(filenames, '*.[ch]'):
|
for filename in fnmatch.filter(filenames, '*.[ch]'):
|
||||||
full_path = os.path.join(root, filename)
|
full_path = os.path.join(root, filename)
|
||||||
|
@ -316,13 +324,18 @@ def main():
|
||||||
continue
|
continue
|
||||||
with open(full_path, encoding='utf-8') as f:
|
with open(full_path, encoding='utf-8') as f:
|
||||||
try:
|
try:
|
||||||
|
include_as = None
|
||||||
for line in f:
|
for line in f:
|
||||||
|
line = line.strip()
|
||||||
|
m = include_as_pattern.search(line)
|
||||||
|
if m:
|
||||||
|
include_as = m.group(1)
|
||||||
# match also ESP_OK and ESP_FAIL because some of ESP_ERRs are referencing them
|
# match also ESP_OK and ESP_FAIL because some of ESP_ERRs are referencing them
|
||||||
if re.match(r"\s*#define\s+(ESP_ERR_|ESP_OK|ESP_FAIL)", line):
|
elif define_pattern.match(line):
|
||||||
try:
|
try:
|
||||||
process(line.strip(), path_in_idf)
|
process(line, path_in_idf, include_as)
|
||||||
except InputError as e:
|
except InputError as e:
|
||||||
print (e)
|
print(e)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
raise ValueError("The encoding of {} is not Unicode.".format(path_in_idf))
|
raise ValueError("The encoding of {} is not Unicode.".format(path_in_idf))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue