diff options
| author | Sebastian Paarz <[email protected]> | 2026-01-09 17:34:00 +0100 |
|---|---|---|
| committer | Sebastian Paarz <[email protected]> | 2026-01-09 17:34:00 +0100 |
| commit | 46d722243f9d814ae03550686ebcb975bfd91dcd (patch) | |
| tree | fe38aecbbc96b5ded58573c8296dbb0f2955d7d4 /samples/demo_netxduo_https.c | |
| parent | a7cf4528de3991c9b4eeb479bcbab7907691448a (diff) | |
| parent | e306027c2f60db4653e120460da523ec561edd1d (diff) | |
Merge remote-tracking branch 'github/master'
Diffstat (limited to 'samples/demo_netxduo_https.c')
| -rw-r--r-- | samples/demo_netxduo_https.c | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/samples/demo_netxduo_https.c b/samples/demo_netxduo_https.c index c4553a67..27ad9784 100644 --- a/samples/demo_netxduo_https.c +++ b/samples/demo_netxduo_https.c @@ -1,3 +1,14 @@ +/*************************************************************************** + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2025 Eclipse ThreadX contributors + * + * This program and the accompanying materials are made available under the + * terms of the MIT License which is available at + * https://opensource.org/licenses/MIT. + * + * SPDX-License-Identifier: MIT + **************************************************************************/ + /* This is a small demo of the NetX Web HTTP Client/Server API running on a high-performance NetX TCP/IP stack. */ /* This demo works for IPv4 only */ @@ -358,8 +369,10 @@ extern const NX_SECURE_TLS_CRYPTO nx_crypto_tls_ciphers; #endif /*NX_WEB_HTTPS_ENABLE */ /* Define the RAM disk memory for FileX demo. */ +#define TOTAL_SECTORS 256 +#define SECTOR_SIZE 512 static UCHAR media_memory[4096]; -static CHAR ram_disk_memory[4096]; +static CHAR ram_disk_memory[TOTAL_SECTORS*SECTOR_SIZE]; static FX_MEDIA ram_disk; /* HTTP server stack area. */ @@ -712,12 +725,15 @@ void https_server_thread_entry(ULONG thread_input) UINT status; UINT server_port; - - NX_PARAMETER_NOT_USED(thread_input); - - fx_media_format(&ram_disk, + /* Format the RAM disk - the memory for the RAM disk was setup in + tx_application_define above. + + Important Note: The user must ensure there is enough RAM for the format + specified. Otherwise, memory corruption can occur. + */ + status = fx_media_format(&ram_disk, _fx_ram_driver, // Driver entry ram_disk_memory, // RAM disk memory pointer media_memory, // Media buffer pointer @@ -726,14 +742,31 @@ UINT server_port; 1, // Number of FATs 32, // Directory Entries 0, // Hidden sectors - 256, // Total sectors - 512, // Sector size + TOTAL_SECTORS, // Total sectors + SECTOR_SIZE, // Sector size 8, // Sectors per cluster 1, // Heads 1); // Sectors per track + /* Determine if the RAM disk format was successful. */ + if (status != FX_SUCCESS) + { + /* Error formatting the RAM disk. */ + printf("HTTPS RAM disk format failed, error: %x\n", status); + return; + } + /* Open the RAM disk. */ - fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, media_memory, sizeof(media_memory)) ; + status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, + ram_disk_memory, media_memory, sizeof(media_memory)); + + /* Determine if the RAM disk open was successful. */ + if (status != FX_SUCCESS) + { + /* Error formatting the RAM disk. */ + printf("HTTPS RAM disk open failed, error: %x\n", status); + return; + } fx_file_create(&ram_disk, "TEST.TXT"); |
