Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
time_change_utility_for_jetson_camera
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikhin.vc
time_change_utility_for_jetson_camera
Commits
270b2a17
You need to sign in or sign up before continuing.
Commit
270b2a17
authored
May 09, 2023
by
sikhin.vc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
46bc8919
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
change_date_time.py
change_date_time.py
+34
-0
No files found.
change_date_time.py
0 → 100644
View file @
270b2a17
import
datetime
import
requests
import
logging
import
ctypes
import
ctypes.util
import
time
def
set_time
(
time_
):
CLOCK_REALTIME
=
0
class
TimesSpec
(
ctypes
.
Structure
):
_fields_
=
[(
"tv_sec"
,
ctypes
.
c_long
),
(
"tv_nsec"
,
ctypes
.
c_long
)]
librt
=
ctypes
.
CDLL
(
ctypes
.
util
.
find_library
(
"rt"
))
ts
=
TimesSpec
()
ts
.
tv_sec
=
int
(
time
.
mktime
(
datetime
.
datetime
(
*
time_
[:
6
])
.
timetuple
()))
ts
.
tv_nsec
=
time_
[
6
]
*
1000000
# Millisecond to nanosecond
librt
.
clock_settime
(
CLOCK_REALTIME
,
ctypes
.
byref
(
ts
))
logging
.
info
(
f
"Successfully set time to {time_}"
)
try
:
response
=
requests
.
get
(
"http://192.168.3.181/camera_api/get_curr_datetime"
)
time_tuple
=
tuple
(
response
.
json
()[
"current_time"
])
logging
.
info
(
f
"Fetched datetime from API : {time_tuple}"
)
set_time
(
time_tuple
)
except
Exception
as
e
:
logging
.
info
(
f
"Failed to update datetime : {e}"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment