~pegro/+junk/rtcwakealarm

« back to all changes in this revision

Viewing changes to ioctlexample.py

  • Committer: Peter Groth
  • Date: 2011-02-18 21:48:47 UTC
  • Revision ID: peter@grothnet.de-20110218214847-yncn4jtrq1za00ip
initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
import fcntl, struct, os
 
4
 
 
5
# Representing
 
6
#  struct rtc_time {
 
7
#    int tm_sec;
 
8
#    int tm_min;
 
9
#    int tm_hour;
 
10
#    int tm_mday;
 
11
#    int tm_mon;
 
12
#    int tm_year;
 
13
#    int tm_wday;
 
14
#    int tm_yday;
 
15
#     int tm_isdst;
 
16
#  };
 
17
# as Python struct.
 
18
a=struct.pack('iiiiiiiii', 0,0,0,0,0,0,0,0,0)
 
19
 
 
20
fo=open('/dev/rtc')
 
21
 
 
22
RTC_RD_TIME=0x80247009
 
23
 
 
24
input=fcntl.ioctl(fo.fileno(), RTC_RD_TIME, a)
 
25
result=struct.unpack('iiiiiiiii', input)
 
26
 
 
27
print "RTC time: " + str(result[2]) + ":" + str(result[1]) + ":" + str(result[0])