3 // Uses the internal 1-wire access routines in ow.c to read the MAC address
4 // from the 2502 on the TINI.
16 unsigned char serial[32];
22 printf("Probing internal one-wire bus...\n");
26 printf("No presence pulse.\n");
30 if (!rc && !owFirst(0, 0))
32 printf("Nothing on internal 1-wire bus.\n");
38 // Find first device of type 89 on internal 1-wire.
40 owSerialNum(serial, 1);
43 printf("found 1-wire device: %02bx%02bx%02bx%02bx%02bx%02bx%02bx%02bx\n",
44 serial[0], serial[1], serial[2], serial[3],
45 serial[4], serial[5], serial[6], serial[7]);
47 } while (serial[0] != 0x89 && owNext(0, 0));
51 if (serial[0] != 0x89)
53 printf("No DS2502 found on internal 1-wire bus.\n");
60 printf("DS2502 located (ID %02bx%02bx%02bx%02bx%02bx%02bx%02bx%02bx).\n",
61 serial[0], serial[1], serial[2], serial[3],
62 serial[4], serial[5], serial[6], serial[7]);
63 /* Build command packet. */
64 serial[0] = 0xCC; /* Skip ROM. */
65 serial[1] = 0xF0; /* Read memory. */
66 serial[2] = 0x00; /* Start address least significant byte. */
67 serial[3] = 0x00; /* start address MSB. */
68 serial[4] = 0xFF; /* listen slot for CRC8 of 1-3. */
70 owBlock(0, serial, 5);
72 myCRC = docrc8(0, serial[1]);
73 myCRC = docrc8(myCRC, serial[2]);
74 myCRC = docrc8(myCRC, serial[3]);
75 if (myCRC != serial[4])
77 printf("read failed: bogus CRC: %bx != %bx\n", myCRC, serial[4]);
84 for (i = 0; i < 32; i++)
88 owBlock(0, serial, 32);
91 printf("DS2502 memory: ");
92 for (i = 0; i < 32; i++)
94 printf("%02bx ", serial[i]);
99 unsigned char *mptr = mac;
100 unsigned char *sptr = &(serial[10]);
102 for (i = 0; i < 6; i++)
108 printf("MAC address: %02bx%02bx%02bx%02bx%02bx%02bx\n",
109 mac[0], mac[1], mac[2],
110 mac[3], mac[4], mac[5]);