1) < char bytes[10] > Should be < unsigned char bytes[10] >;
2) In printf "%d" should be "%u";
At last u wrongly Interpreted the Hex Numbers,
"hour: 22 (fifth byte)...but 22 in hex is 16!"
Actually 22 is already in Hex, how u calculate the 16, ???
Regards:
Pulkit Goel
mail: vipulkit.goel@xxxxxxxxx
email@xxxxxxxxxxxxxx
On Mon, Nov 30, 2009 at 2:47 AM, Martin Knappe <martin.knappe@xxxxxxxxx> wrote:
hi
this worked thanks
i am now trying to play around with my homegrown cmos driver...
according to this site: http://www.ousob.com/ng/interrupts_and_ports/ng9116b.php
the first byte i read from my device node (/dev/cmos0) tells me the seconds in the hardware clock
i have written a little test program that goes like this:
int main()
{
int fd = open("/dev/cmos0", O_RDONLY);
if (fd < 0) {
printf("cannot open\n");
exit(1);
}
char bytes[10];
int i = 0;
lseek (fd, 0, SEEK_SET);
if (read(fd, &bytes, sizeof(bytes)) != sizeof(bytes)) {
printf("I/O problem\n");
exit(1);
}
for (i = 0; i < sizeof(bytes); i++) {
printf("%d\tread: %d\n", i, (char) (bytes[i]));
}
}
when i execute this, is get something like this:
0 read: 71
1 read: 2
2 read: -40
3 read: -38
4 read: -49
5 read: -65
6 read: 57
7 read: -122
8 read: 4
9 read: 8
when i execute this repeatedly, the first byte i read does indeed change, so it seems it's got something to do with the clock, but second 71 doesnt make sense!
also, the third line is supposed to represent the minutes (-40???)
whats even stranger is the following, when i open /dev/cmos0 with hexedit, i get the following (first few bytes):
00 FE 06 96 22 3E 06 29 11 09 26 02 50 C0 00 00 40 30 00 30
this, strangely enough, makes perfect sense...
minute: 6 (3rd byte)
hour: 22 (fifth byte)...but 22 in hex is 16!
day of the week: 6 (7th byte)
day of the month: 29 (8th byte) but 29 in hex would be 1d
can someone explain that??On Sat, Nov 28, 2009 at 9:20 PM, Pulkit Goel <vipulkit.goel@xxxxxxxxx> wrote:
Hi Martin,
Check < cat /proc/ioports > prints all ioport addresses.
you should check the following function for good details.#include <linux/ioport.h>
int check_region(unsigned long start, unsigned long len);
struct resource *request_region(unsigned long start,
unsigned long len, char *name);
void release_region(unsigned long start, unsigned long len);
Regards:
Pulkit Goel
mail: vipulkit.goel@xxxxxxxxx
email@xxxxxxxxxxxxxx
On Fri, Nov 27, 2009 at 3:09 AM, Matthias Kaehlcke <matthias@xxxxxxxxxxxx> wrote:hi martin,
El Thu, Nov 26, 2009 at 10:26:07PM +0100 Martin Knappe ha dit:
'cat /proc/ioports' should give you a clue
> ive written a simple cmos driver and try to load it
> but when i do insmod, i get
>
> [ 9664.617003] cmos: I/O port 0x70 is not free.
>
> how can i find out which other module is using this port?
best regards
--
Matthias Kaehlcke
Embedded Linux Developer
Barcelona
You can't separate peace from freedom because no
one can be at peace unless he has his freedom
(Malcolm X)
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ