-
Notifications
You must be signed in to change notification settings - Fork 578
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
Add CSI Framework and CSI driver #6399
base: master
Are you sure you want to change the base?
Conversation
@@ -1650,6 +1669,9 @@ CONFIG_EXAMPLE_LCD_FPS_TEST=5000 | |||
# | |||
# CONFIG_EXAMPLES_TAHI is not set | |||
# CONFIG_EXAMPLES_WIFIMANAGER_TEST is not set | |||
# CONFIG_WIFIMANAGER_TEST_TRIAL=5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'# CONFIG_WIFIMANAGER_TEST_TRIAL is not set
'# CONFIG_EXAMPLES_WIFIMANAGER_AP_LIST_ITEMS_COUNT is not set
@@ -1274,6 +1289,9 @@ CONFIG_DEBUG_ERROR=y | |||
# Subsystem Debug Options | |||
# | |||
# CONFIG_DEBUG_AUDIO is not set | |||
CONFIG_DEBUG_WIFICSI=y | |||
CONFIG_DEBUG_WIFICSI_ERROR=y | |||
CONFIG_DEBUG_WIFICSI_INFO=y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default is Error
6db8ae7
to
7052d42
Compare
7052d42
to
67c2816
Compare
67c2816
to
7052d42
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- There are so many coding rules violations.
UDP server support to send CSI data to UDP client
is not proper in commit rules.
framework/src/csifw/CSILogsDumper.c
Outdated
{ | ||
print_log("\n RAW DATA %d\n\n", len); | ||
unsigned long long *buff_tmp = (u64 *)buf; | ||
int buff_len = (len/8) + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len / 8
framework/src/csifw/CSILogsDumper.c
Outdated
|
||
void set_event_listener(csiDataDumpListener listener) | ||
{ | ||
gListener = listener; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coding rule violation.
tab for indentation
same as other lines
framework/src/csifw/CSILogsDumper.c
Outdated
} | ||
} | ||
|
||
CSIFW_RES csi_logs_dumper_init() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should add void
fclose(file); | ||
close(sockfd); | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to check the warning
framework/src/csifw/CSILogsDumper.c
Outdated
return CSIFW_ERROR; | ||
} | ||
|
||
if (pthread_create(&gThreadId, NULL, dataTransmitter, NULL) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you create a pthread, you should call pthread_join or pthread_detach. If you don't, it will have a memory leak.
@@ -1031,6 +1031,12 @@ CONFIG_LWNL80211=y | |||
# CONFIG_DEBUG_LWNL80211_VENDOR_DRV_ERROR is not set | |||
CONFIG_NET_LOOPBACK_INTERFACE=y | |||
|
|||
# WIFI CSI Support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DO NOT modify defconfig manually.
After doing through menuconfig, and then copy changes into the defconfig.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
os/Kconfig.debug
Outdated
@@ -45,6 +45,38 @@ config DEBUG_VERBOSE | |||
|
|||
comment "Subsystem Debug Options" | |||
|
|||
config DEBUG_WIFICSI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add it by Alphabet order to find it easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
int ret; | ||
|
||
csivdbg("minor %d\n", minor); | ||
printf("minor %d\n", minor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated, this line should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
os/drivers/Kconfig
Outdated
|
||
if !WIFICSI_DEV_ROOT | ||
|
||
config WIFICSI_DEV_PATH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is difference between WIFICSI_CUSTOM_DEV_PATH
and this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obsolete, it has been removed now.
os/drivers/wifi_csi/Make.defs
Outdated
ifeq ($(CONFIG_WIFI_CSI_RTL8730E),y) | ||
CSRCS += rtk_wifi_csi.c | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The driver should be common. This should be in Make.defs of RTL8730E, not here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, done.
* language governing permissions and limitations under the License. | ||
* | ||
****************************************************************************/ | ||
#ifndef __INCLUDE_TINYARA_WIFI_CSI_COMMON_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you able to distinguish wifi_csi.h
and wifi_csi_common.h
in usage? How about renaming them to know what it is from the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many basic things are missing like license, coding rules, commit rules.
# see kconfig-language at https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt | ||
# | ||
|
||
config EXAMPLES_CSIFW_TEST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a framework. How about splitting a commit for app from framework commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
static int print_log(const char *format, ...) | ||
{ | ||
|
||
va_list args; | ||
va_start(args, format); | ||
|
||
vprintf(format, args); | ||
va_end(args); | ||
return 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you let me know why you use this function instead of printf
? Any advantage???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to printf.
framework/src/csifw/Make.defs
Outdated
|
||
ifeq ($(CONFIG_CSIFW), y) | ||
|
||
CFLAGS += -I${TOPDIR}/os/include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be unnecessary. Let's remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
a6cb430
to
ebeda22
Compare
ebeda22
to
f012e25
Compare
c48276c
to
b87ebb7
Compare
os/drivers/wifi_csi/wifi_csi.c
Outdated
if (upper->crefs > 1) { | ||
upper->crefs--; | ||
} else { | ||
FAR struct wifi_csi_lowerhalf_s *lower = upper->dev; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, corrected.
os/drivers/wifi_csi/wifi_csi.c
Outdated
ret = lower->ops->getcsidata(lower, buf_arg->buffer, buf_arg->buflen); | ||
} else { | ||
csidbg("ERROR: Unsupported operation: getcsidata\n"); | ||
ret = ENOTSUP; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ENOSYS is better option.
If driver has not implemented function, then ENOSYS
But driver dosn't support by given configuration or something, then ENOTSUP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh right! thanks.
* call via its callback pointer to our upper-half driver. | ||
* | ||
****************************************************************************/ | ||
static inline void wifi_csi_data_ready(FAR struct wifi_csi_upperhalf_s *upper, char *buff, uint32_t csi_data_len) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type need to be changed int, and it should return some of errno if upper->usermq is null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wifi_csi_data_ready
is a callback, so where would I check the return type, all callers are themselves void callbacks. (cannot return anything as no one is there to check ret value)
wifi driver sends data ready callback --> void lower_driver_data_readyCB() --> void wifi_csi_callback() --> void wifi_csi_data_ready()
framework/include/csifw/csifw_api.h
Outdated
* | ||
* @param[in] raw_callback Callback function for receiving raw CSI data. Pass NULL if raw csi data not required. | ||
* @param[in] parsed_callback Callback function for receiving parsed CSI data. Pass NULL if parsed csi data not required. | ||
* @param[in] interval Data collection interval in microseconds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add description for void *ptr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
framework/src/csifw/CSIService.c
Outdated
{ | ||
if (g_service_state == CSI_COLLECT_STATE_STARTED) { | ||
CSIFW_LOGE(" Already running"); | ||
return CSIFW_ERROR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should provide some kind of CSIFW_ERROR_WRONG_STATE or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
State is an internally maintained f/w property, so I followed the practice to not inform the app about f/w state.
In current case, the app developer will receive error and message that "CSIFW is already started".
But if still the change is needed, please tell, I'll correct it.
} | ||
csi_packet_receiver_start_collect(&g_csifw_config); | ||
ping_generator_start(); | ||
g_service_state = CSI_COLLECT_STATE_STARTED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it working based on state, then some kind of pthread_mutex_lock is required. to prevent change state in multiple thread environment
framework/src/csifw/CSIService.c
Outdated
CSIFW_RES csi_service_stop(CSIFW_REASON reason) | ||
{ | ||
if (g_service_state != CSI_COLLECT_STATE_STARTED) { | ||
CSIFW_LOGE("Already stopped"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CSIFW_LOGE("stop error state : %d\n", g_service_state);
because it can be one of 4 states.
sleep(5); | ||
|
||
PRNT_LN3; | ||
csi_action_param_t config = {0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most of app developer can't understand what this config means exactly.
so please refer to below.
some_csi_init_in_framework()
{
/* Initialize Base value Here */
g_config.group_num = CSI_GROUP_NUM_1;
g_config.mode = CSI_MODE_NORMAL;
g_config.accuracy = CSI_ACCU_1BYTE;
g_config.ch_opt = CSI_CH_NON_LEGACY;
g_config.trig_period = 200;
g_config.data_rate = CSI_DATA_RATE_HIGH...; //0x80 is impossible to understand what it means.
}
csi_set_group_num(int num)
{
if (state_is_wrong) {
return CSIFW_ERROR_STATE;
}
g_config.group_num = num;
}
A better way is that structure in driver need to be avoided, so it should work without csi_service_set_config based on basic setting value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually for the application to get data, they must configure what specific kind of csi data is required.
with some_csi_init_in_framework()
do you wish to provide option to use default config for an app-developer who does not have info about config? And then provide apis (like csi_set_group_num()
)for every config component, so that they can only change the config they are known to?
framework/src/csifw/CSILogsDumper.c
Outdated
printf("\n RAW DATA %d\n\n", len); | ||
unsigned long long *buff_tmp = (u64 *)buf; | ||
int buff_len = (len / 8) + 1; | ||
for (int i = 0; i < buff_len; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to our coding rule, add bracket even if it is single line of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is fixed
b87ebb7
to
b58eb64
Compare
b58eb64
to
ec9f44c
Compare
ec9f44c
to
1d7c6a2
Compare
102406d
to
6d1c3b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still many coding rules violations.
config ENTRY_CSIFW_TEST | ||
bool "CSI Framework example" | ||
depends on EXAMPLES_CSIFW_TEST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To use this, you should add config USER_ENTRYPOINT
in the Kconfig. Please refer other example.
return 0; | ||
} | ||
|
||
void csi_manager_csifw_test_init(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you let me know who executes this?
while (1) { | ||
sleep(2); | ||
} | ||
// sleep(15); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to keep commented codes?
PRNT_LN1; | ||
PRNT_LN2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you let me know purpose of them, PRNT_LN1, LN2 and LN3?
|
||
#if LOG_PARSED_DATA | ||
printf("[APP] Displaying parsed data, csi_data_len: %d\n\n", csi_data_len); | ||
for(int i = 0; i < csi_data_len; i += 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (
framework/src/csifw/CSIParser.c
Outdated
CSIFW_LOGI("PRINTING PARSED DATA"); //csi_sequence, timestamp | ||
printf("\n csi_buff_len (with header): %d, only csi len: 112",csi_buff_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When do you use CSIFW_LOGx
or printf
?
framework/src/csifw/CSIParser.c
Outdated
CSIFW_LOGI("%d,%d,", csi_seq_num, timestamp); //csi_sequence, timestamp | ||
|
||
printf("0x%x%x,", csi_buff[1], csi_buff[0]); //csi_signature | ||
printf("0x%x,", csi_buff[2]); //hdr_len | ||
CSIFW_LOGI("%x:%x:%x:%x:%x:%x,", csi_buff[8],csi_buff[7],csi_buff[6],csi_buff[5],csi_buff[4], csi_buff[3]); //mac_addr | ||
CSIFW_LOGI("%x:%x:%x:%x:%x:%x,", csi_buff[14],csi_buff[13],csi_buff[12],csi_buff[11],csi_buff[10], csi_buff[9]); //trig_mac_addr | ||
CSIFW_LOGI("%d,", ((int)csi_buff[31]/2 - 110)); //rssi | ||
|
||
// CSIFW_LOGI("%s,",argv[1]); //real | ||
CSIFW_LOGI("%d,", (int)csi_buff[19]); //channel, infered |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we are ok to print all raw data defaultly. I don't mean this highlighted lines only. There are many data printing in the framework.
framework/src/csifw/CSIService.c
Outdated
CSIFW_RES csi_manager_init(void) | ||
{ | ||
CSIFW_LOGI("[CSIFW] initialization function is called\n"); | ||
return CSIFW_OK; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function looks unnecessary. Could you check it?
framework/src/csifw/CSIService.c
Outdated
static void csi_data_dump_listener(EVENT event) { | ||
CSIFW_LOGD("csi_data_dump_listener called\n"); | ||
gCSIDataDumpEvent = event; | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary
if (!dev) { | ||
csidbg("ERROR: dev null\n"); | ||
return; | ||
} | ||
if (!priv) { | ||
csidbg("ERROR: priv null\n"); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any case which dev is NOT null and priv is null? I mean that checking priv is necessary?
Hello all, thankyou for the suggestions, the pending comments will be resolved soon along with sync-up with internal developments. |
4f0b886
to
469d706
Compare
framework/src/csifw: CSIFW source code framework/include/csifw: CSIFW headers os/drivers/wifi_csi: Add driver source code os/board: Enable driver register at bootup os/include/tinyara/wifi_csi/wifi_csi_struct.h: Define commmon wifi csi kernel constants and structures.
Add CSI Framework
framework/serc/csifw: CSIFW source code
framework/include/csifw: CSIFW headers
apps/examples/csifw_test: Sample csifw app.
Add WIFI CSI Driver
os/drivers/wifi_csi: Add driver source code
os/board: Enable driver register at bootup
build/configs: Enable driver flags