Use uint8_t in Kconfig.projbuild

Saskia
Posts: 40
Joined: Mon Jun 26, 2017 11:45 am

Use uint8_t in Kconfig.projbuild

Postby Saskia » Tue Aug 08, 2017 6:15 pm

I want to use the Kconfig.projbuild file, there should be a parameter as uint8_t. But this is not possible, only int (or string).

this is working

Code: Select all

config mac
    string "mac"
	default "{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}"
but i want to use this as uint8_t. Int is not working with this syntax. "You have made an invalid entry."

String is the only datatype working. Is it possible to cast this into uint8_t?

Saskia
Posts: 40
Joined: Mon Jun 26, 2017 11:45 am

Re: Use uint8_t in Kconfig.projbuild

Postby Saskia » Thu Aug 10, 2017 9:27 pm

No one?

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: Use uint8_t in Kconfig.projbuild

Postby loboris » Thu Aug 10, 2017 11:13 pm

Parameters in Kconfig.projbuild are constants, if you need you can limit the range

Code: Select all

    config MY_CONFIG_OPTION
        int "My config option"
        range 0 255
        default 64
        help
        Enter the valu which wil be assigned to uint8_t variable
Then use it in your code

Code: Select all

#include sdkconfig.h

uint8_t myvalue = CONFIG_MY_CONFIG_OPTION
....
kconfig-language

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Use uint8_t in Kconfig.projbuild

Postby WiFive » Thu Aug 10, 2017 11:48 pm

Right but he wants to do a Mac address so he would have to do a different entry for each octet (type hex) which seems to be the most common method. Or use a string and then convert the string to a byte array. What is the best way to do that at compile time?

Saskia
Posts: 40
Joined: Mon Jun 26, 2017 11:45 am

Re: Use uint8_t in Kconfig.projbuild

Postby Saskia » Fri Aug 11, 2017 11:06 am

Yeah, i convert it to a byte array, thanks. But i have another problem. I can't get access to this String in my main.c:

My Kconfig.projbuild looks like this

Code: Select all

menu "Settings"

config MAC
    string "mac"
    default "AAAAAAAAAAAA"
    help
        Enter a value
my library "settings.h" looks like this

Code: Select all

#ifndef settings_h
#define settings_h

#define MAC CONFIG_MAC

#endif
At this pont, i get this error

Code: Select all

error: 'MAC' was not declared in this scope
hwo can i link MAC to a variable, which i can use in main.c (for examle CONFIG_MAC)?

User avatar
rudi ;-)
Posts: 1727
Joined: Fri Nov 13, 2015 3:25 pm

Re: Use uint8_t in Kconfig.projbuild

Postby rudi ;-) » Sun Aug 13, 2017 11:43 am

Saskia wrote:
my library "settings.h" looks like this

Code: Select all

#ifndef settings_h
#define settings_h

#define MAC CONFIG_MAC

#endif
At this pont, i get this error

Code: Select all

error: 'MAC' was not declared in this scope
hwo can i link MAC to a variable, which i can use in main.c (for examle CONFIG_MAC)?
where is your library file named "settings.h" `?
is this in a include folder?
have you include this file where you define MAC in the main.c

Code: Select all

#include  "settings.h"
usually is this done by include the config like boris you suggest

Code: Select all

#include sdkconfig.h

uint8_t myvalue = CONFIG_MY_CONFIG_OPTION
....

so you must be sure that you have your own defines and configs included in your code and in your makefile if have different custom code - cause the linker does not know, where you have your settings.h so you must say him where he find your customs defines.

hope this helps

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

Who is online

Users browsing this forum: tahseenabbas52 and 96 guests