3 // Uses the internal 1-wire access routines in ow.c to read the MAC address
4 // from the 2502 on the TINI.
14 unsigned char serial[32];
20 printf("Probing internal one-wire bus...\n");
24 printf("No presence pulse.\n");
28 if (!rc && !owFirst(0, 0))
30 printf("Nothing on internal 1-wire bus.\n");
36 // Find first device of type 89 on internal 1-wire.
38 owSerialNum(serial, 1);
41 printf("found 1-wire device: %02x%02x%02x%02x%02x%02x%02x%02x\n",
42 serial[0], serial[1], serial[2], serial[3],
43 serial[4], serial[5], serial[6], serial[7]);
45 } while (serial[0] != 0x89 && owNext(0, 0));
49 if (serial[0] != 0x89)
51 printf("No DS2502 found on internal 1-wire bus.\n");
58 printf("DS2502 located (ID %02x%02x%02x%02x%02x%02x%02x%02x).\n",
59 serial[0], serial[1], serial[2], serial[3],
60 serial[4], serial[5], serial[6], serial[7]);
61 /* Build command packet. */
62 serial[0] = 0xCC; /* Skip ROM. */
63 serial[1] = 0xF0; /* Read memory. */
64 serial[2] = 0x00; /* Start address least significant byte. */
65 serial[3] = 0x00; /* start address MSB. */
66 serial[4] = 0xFF; /* listen slot for CRC8 of 1-3. */
68 owBlock(0, serial, 5);
70 myCRC = docrc8(0, serial[1]);
71 myCRC = docrc8(myCRC, serial[2]);
72 myCRC = docrc8(myCRC, serial[3]);
73 if (myCRC != serial[4])
75 printf("read failed: bogus CRC: %x != %x\n", myCRC, serial[4]);
82 for (i = 0; i < 32; i++)
86 owBlock(0, serial, 32);
89 printf("DS2502 memory: ");
90 for (i = 0; i < 32; i++)
92 printf("%02x ", serial[i]);
97 unsigned char *mptr = mac;
98 unsigned char *sptr = &(serial[10]);
100 for (i = 0; i < 6; i++)
106 printf("MAC address: %02x%02x%02x%02x%02x%02x\n",
107 mac[0], mac[1], mac[2],
108 mac[3], mac[4], mac[5]);