Commit Graph

31 Commits

Author SHA1 Message Date
Dean Lee
7ff2217c8b util: remove function to_hex (#22792)
old-commit-hash: ff33ca341382be19a4be9bd71b97af1b01b553c7
2021-11-04 16:18:01 +01:00
Dean Lee
a602b4a1a0 util:: remove unused funtion base_name (#22759)
old-commit-hash: 8da3cd3cdd6fdf82960f393c79db6ce5098b3f44
2021-10-31 13:10:27 -07:00
Dean Lee
ebffd5f3ad util: add safe write functions (#22160)
* add safe write functions

* log error

* bzfile safe_fopen&safe_flush

* update test_case

* trigger ci

Co-authored-by: Willem Melching <willem.melching@gmail.com>
old-commit-hash: 652c42da2c6fa31168d5d299c959ab0c86799c4b
2021-10-29 13:23:31 +02:00
Dean Lee
0afe7d74bc util: add new function create_directories with unit tests (#21871)
* util::create_directories

* check bool ret

* don't assume mask

* rename with_umask to no_umask

* remove umask

* rebase master

* rebase master

* 0755
old-commit-hash: 1f39d8cee69cf28576cd9bd27ef52be57d44371e
2021-10-29 12:27:35 +02:00
Adeeb Shihadeh
25cfa2b65a tici: affine loggerd to efficiency cores (#22581)
old-commit-hash: 84de248fa7cbee37ecb2fd6a9d4df50ba60a1e04
2021-10-18 13:21:24 -07:00
Dean Lee
48b7754ab5 fix: util::read_files_in_dir does not always return a correct result (#21883)
* fix bug

* use de->d_type==DT_REG

* Revert "use de->d_type==DT_REG"

This reverts commit ecb38c82305ea23bfec84284aa77be5b5c64957a.
old-commit-hash: 83710b14ee8cf043576dba8f3707fc585067167e
2021-09-01 15:10:59 -07:00
Dean Lee
4c17c06799 Handle EINTR for all syscalls that can return it (#21948)
old-commit-hash: f02c8d0e2c04e45ceeea9f2fe9851319d724a637
2021-08-31 16:22:56 -07:00
Dean Lee
16c727b65c fix: util::file_exists will return false on no permissions (#21880)
* fix bug

* add test case
old-commit-hash: 3a7959b5ffff6f866e592fc815692ec469f4fbb6
2021-08-09 11:56:45 +02:00
Dean Lee
94d534afea hw.h: move Hardware-related paths to namespace Path (#21826)
* refactor getenv and path

* apply review
old-commit-hash: fefc70b4cab71a11b3c5ed1b8680606ee2013a48
2021-08-04 13:29:03 +02:00
Dean Lee
c40edd4b56 qt/util: new function getDongleId (#21810)
* new function getDongleId

* return std::optional
old-commit-hash: 073b96e5d16c4780ed4adfb50b506fa1afd40d68
2021-08-02 11:21:51 +02:00
Dean Lee
31ea9413bb util/read_files_in_dir: return map by value (#21815)
old-commit-hash: 11ffbc693694780c612d9d449f49a2feabe8a0a2
2021-08-02 10:59:54 +02:00
Willem Melching
32cde15035 bump date in time_valid check
old-commit-hash: 86630effcfd8e1aee71e11a79937714de6379757
2021-06-30 12:18:53 +02:00
Dean Lee
f03ca47c9c util.cc: refactor read_file (#21350)
old-commit-hash: ac71384a28cda46126ea5d699697bb7ab701d972
2021-06-22 13:48:41 -07:00
Adeeb Shihadeh
28a9781c51 util::read_file: fix reading from sysfs and add test case (#21325)
* add sysfs test case

* Revert "util.cc: refactor read_file (#21321)"

This reverts commit 2a9ba3e867e4ba8ea8818a5be24807301a945f17.
old-commit-hash: d90d9b2280397bb113c0d5835810cbd5f483f2a1
2021-06-18 01:34:52 -07:00
Dean Lee
0ef41b3e94 util.cc: refactor read_file (#21321)
* mode read & open once

* change return statement for better readibility

* apply reviews

* can't open with ate flag
old-commit-hash: 8d5c61eefe91f9f62ae8109e2c0c32ed2778e770
2021-06-17 23:19:41 -07:00
Adeeb Shihadeh
2476a66cd9 Revert "util.cc: refactor read_file (#21295)"
This reverts commit 32dd5c2454e3f3fca028dacd24bc4758e1134295.

old-commit-hash: 7dec2064370255e00f719ea790c26bd00edbdb6f
2021-06-17 15:02:48 -07:00
Dean Lee
b83e0f87a8 util.cc: refactor read_file (#21295)
* mode read & open once

* change return statement for better readibility

* apply reviews

* Update selfdrive/common/util.cc

* fix

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: 190a845505b1142166e8b25d953ab20d19276b87
2021-06-17 14:03:07 -07:00
Dean Lee
6bfc7f4ca5 common/util.cc: add unit test, fix bug in util::read_file (#21251)
* add test case for util

* fix bug in read_file

* gitignore test_util

* better test

* referer

* more

* more test

* REQUIRE size

* apply reviews

* only test binary

* simplify the test

* read  non-permission

* debug print

* remove /etc/shadow

* test read directory

* Update selfdrive/common/tests/test_util.cc

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Co-authored-by: Willem Melching <willem.melching@gmail.com>
old-commit-hash: a873a23e0dbfe43027911acdd270610048eed74a
2021-06-16 11:01:13 +02:00
Willem Melching
196f96f057 UI: check if dongle id is valid before calling API (#21275)
old-commit-hash: e85fa7f1c933baafdecb4a52c16f2003215d423b
2021-06-15 14:10:44 +02:00
Dean Lee
147b355dde add space after function name and if statement (#21225)
old-commit-hash: e4e669bb0fc1a919dfb38800099f8e3ad52346f1
2021-06-11 10:17:52 +02:00
Dean Lee
51cf285c31 Passing arguments by reference (#21205)
old-commit-hash: ee46672d3c8c86b41fd8ae2fce9120e050b8e628
2021-06-09 14:09:02 +02:00
Dean Lee
f70a79b838 Use C++ header files instead of C header files. (#21192)
* use cstring instead of string.h

* use cstdio instead of stdio.h

* remove inttypes.h

* use cstdlib instead of stdlib.h

* use cstdint instead of stdint.h

* #include <cstddef>

* cstdlib

* use cmath

* remove stddef.h

* use cassert

* use csignal

* use ctime

* use cerror

* rebase master
old-commit-hash: c53cb5d570adb82bc454fcabab458d7e7f09738c
2021-06-08 13:46:22 -07:00
Dean Lee
497472932a Cleanup util.h (#20849)
* cleanup util.h

* fix build error:omx_encoder.cc:408: undefined reference to do_exit

* fix build error

* rebase master

* move helper functions back to util

* ExitHandleHelper->ExitHandlerHelper

* std::clamp

* struct ExitHandlerHelper to class

* rebase master

* cleanup

* restore ExitHandler

* prefer cassert
old-commit-hash: 65e0b1e699092355bfcb1f588a5a2ec949a34b77
2021-06-01 16:53:12 +02:00
Dean Lee
badc577e1d read_files_in_dir: closedir before return (#20903)
old-commit-hash: c08ee575f82b1040d99e90e44449bbb83307d8a5
2021-05-14 17:33:46 -07:00
Willem Melching
8b785f4744 store all files in /sys/fs/pstore in bootlog (#20875)
* store all files in /sys/fs/pstore in bootlog

* whitespace

* fix bootlog test
old-commit-hash: 4742f55749e59f565192589b318841f2133260ed
2021-05-12 11:15:54 +02:00
Dean Lee
e333e4f189 Cleanup selfdrive/ includes (#20822)
* cleanup include path

* continue

* format includes

* fix testraw.cc

* remove include path from SConstruct

* regroup

* rebase master

* almost done

* apply review

* rename FileReader.xx to filereader.xx

* rename Unlogger.x->unlogger.x

* rename FrameReader.xx -> framereader.xx

* apply reviews

* ui.h

* continue

* fix framebuffer.cc build error:mv util.h up

* full path to msm_media_info

* fix qcom2 camerad

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: 7222d0f20dc8edfe0d2f3417d1ce7c84fbd32805
2021-05-08 22:15:17 -07:00
Adeeb Shihadeh
829afdfb87 ate sets failbit on some platforms
old-commit-hash: d90136c1d055369024b1223b0ead520f5aad5913
2021-04-13 14:40:40 -07:00
Comma Device
6f27d70605 fix reading procfs files
old-commit-hash: 6f21993915dd64ac145ec8a17686b62d909fc8f1
2021-04-13 13:56:08 -07:00
Dean Lee
7534abdd50 util.cc: reduce two read_file functions into one (#20655)
* no need to malloc one extra byte

* combine two read_file into a faster one

* cleanup #include

* use resize

* apply suggestions from review

* space

* rebase master
old-commit-hash: fe2f63849ae467fee70c72d18fa52a184c056331
2021-04-13 11:43:43 -07:00
Willem Melching
4d6c98aa6b Add watchdog check to manager (#20277)
* this should work but doesnt

* Only offroad

* works

* make it work offorad

* reduce diff

* cleanup

* need util

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: a94ba4fb8b704a5462352af4501290f63c987754
2021-03-08 19:17:46 -08:00
Dean Lee
4c1919f41e merge utilpp.h into util.h (#19710)
old-commit-hash: 595830135bb79c8b23eb8339ae768ca7b6a822f8
2021-01-10 14:57:32 -08:00