Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 FILE_WRITE overflow: O_APPEND and O_CREAT is defined different #151

Open
MaDill opened this issue Apr 27, 2024 · 0 comments
Open

ESP32 FILE_WRITE overflow: O_APPEND and O_CREAT is defined different #151

MaDill opened this issue Apr 27, 2024 · 0 comments

Comments

@MaDill
Copy link

MaDill commented Apr 27, 2024

I have a strange error. I port my code from an arduino uno to ans ESP32. I use the SD library version 1.2.4

When I want to open a file with mode FILE_WRITE I receive a compiler error:

"message": "unsigned conversion from 'int' to 'uint8_t' {aka 'unsigned char'} changes value from '523' to '11' [-Woverflow]",
"startLineNumber": 24,
"startColumn": 48,
"endLineNumber": 24,
"endColumn": 48

(O_READ | O_WRITE | O_CREAT | O_APPEND) is defined in SdFat.h as

uint8_t const O_READ = 0X01;
uint8_t const O_WRITE = 0X02;
uint8_t const O_CREAT = 0X10;
uint8_t const O_APPEND = 0X04;

Should be 23 (DEC)

I then tried to create the FILE_WRITE by myself and see in VSCode that it is expanded to:

O_READ = 1
O_WRITE = 2
O_CREAT = 0x0200
O_APPEND = 0x0008

and this is 523 (DEC)

The used O_CREATE is from:
.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\sys-include\sys\_default_fcntl.h
line 51:

#define	O_APPEND	_FAPPEND

line 52:

#define	O_CREAT		_FCREAT

line 12:

#define	_FAPPEND	0x0008	/* append (writes guaranteed at the end) */

line 18:

#define	_FCREAT		0x0200	/* open with file create */

This is from my platformio.ini:

platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
	arduino-libraries/SD@^1.2.4
	fbiego/ESP32Time @ ^2.0.6
check_skip_packages = yes

Installed is https://github.com/platformio/platform-espressif32 in version 6.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant