How to talk with RTC hardware by Python?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to talk with RTC hardware by Python?

856 Views
jackbk
Contributor I

I am using DT6 custom board from Variscite . This board is connect with DART MX6 board. DT6 in below link

http://www.variscite.com/products/single-board-computers/dt6customboard

I need to handle the RTC hardware on DT6 board by Python. This RTC named ISL12057. I google some info and I understand as follows.

- ISL12057 is same as DS1307. There is a library of Python for DS1307 as link

http://www.switchdoc.com/2014/07/python-driver-ds1307-real-time-clock/ 

I try this Python library, but I do not understand this library well. So I have some questions as below. Can you answer them? I appreciate your support.

1. As I list in `/dev/`, it has `i2c-0`, `i2c-1`, `i2c-2`. I do not know which I2C that connect to my RTC. I tried 3 of them by `smbus.SMBus(0)`, `smbus.SMBus(1)`, `smbus.SMBus(2)`, there are 2 kinds of error.

1.1 IOError: [Errno 16] Device or resource busy

1.2 IOError: [Errno 5] Input/output error

So, firstly, how can I solve `1.1` or `1.2` to talk with my RTC?

2. I have no experience with Python that can talk with RTC hardware. so, if my usage of DS1307 library for my ISL12057 is not correct, could you tell me another way?

3. ISL12057 has an interrupt function at each second or each minute. In Python, can we detect that interrupt when it is asserted?

0 Kudos
2 Replies

210 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hello Jack,

     Questions on how to read RTC time value on linux OS is not within our support range. I only give you some advice!

(1) About DS1307

In it's driver source code, APIs are supported, like following:

static const struct rtc_class_ops ds13xx_rtc_ops = {
    .read_time    = ds1307_get_time,
    .set_time    = ds1307_set_time,
    .read_alarm    = ds1337_read_alarm,
    .set_alarm    = ds1337_set_alarm,
    .alarm_irq_enable = ds1307_alarm_irq_enable,
};

So you can use above 5 functions in your appliction to read/modify Real Time.

But I checked driver source code of ISL12057, APIs are not supported in drivers, So you can't operate RTC on application Level.

(2) rtc device path

Generally, rtc device should be /dev/rtc/rtc0,1,2.... or /dev/misc/rtc/rtc0,1,2.... you can check and confirm it in your linux system.

Hope above information is helpful for you!

Best Regads,

Weidong

0 Kudos

210 Views
jackbk
Contributor I

Hello Weidong,

Thank you for your advice!

My question is not within your support range. But I think the i.MX forum can solve many questions related to the boards from Variscite. I am using a board of Variscite, and I know that there are many experts can solve my issue.

Do I need to move my question to suitable Category in i.MX forum?

0 Kudos