Forum Rule: Always post complete source code & details to reproduce any issue!
Page 4 of 4 FirstFirst ... 2 3 4
Results 76 to 86 of 86

Thread: teensy 3 MAC address

  1. #76
    I wish my brain would work binary like yours and other peoples here.
    Things i need hours or days you do in minutes.

    Serial output looks nice now:
    Code:
    The radio frequency is 868 Mhz, Kenneth!
    RFM69 ATC Enabled (Auto Transmission Control)
    
    I2C Address Scanning ...
    Found i2c Device Address: 32 (0x20)
    Found i2c Device Address: 33 (0x21)
    Scanning done!
    Found 2 device(s).
    
    Reading MAC from hardware...
    Success! Setting MAC address:
      Ethernet MAC = 04 E9 E5 03 A7 AE
    
    Starting Network...
      Connected to Network!
      IPv4 address: 192.168.0.246
    
    Syncing with NTP Server...
    Transmitting NTP Request...
    Receiving NTP Response...
    RTC has set the system time
    Time: 6:01:18 22 1 2017

  2. #77
    Senior Member Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    3,786
    Great that it works now :-)

    You can print the MAC without loop, too:
    Code:
     Serial.printf("Ethernet MAC = %02X:%02X:%02X:%02X:%02X:%02X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
    These are, again, format-strings. "%02X" means print the number as 2-digit hexadecimal, with leading zero, uppercase. ("%02x" would be lowercase)
    Last edited by Frank B; 01-22-2017 at 09:21 AM.

  3. #78
    Junior Member
    Join Date
    Sep 2016
    Posts
    16
    I have made a new library called TeensID based on the TeensyMAC lib from frank.
    You can find it at https://github.com/sstaub/TeensyID
    I have extended the library with pointers and strings for MAC, USB#, Serial# and ChipID
    It is only tested for Teensy 3.5
    Last edited by sstaub; 02-13-2017 at 09:06 AM.

  4. #79
    Senior Member defragster's Avatar
    Join Date
    Feb 2015
    Posts
    4,386
    Glancing at the code it looks like it has FrankB's work to get serial # before hsrun_disable was introduced for T_3.6 - that catching it in startup. Though that code is also there? The core of the code needs only do the work below to get the Serial #.

    The PJRC code to set the Serial Number is here: teensy3/usb_desc.c#L1294

    void usb_init_serialnumber(void)
    {
    char buf[11];
    uint32_t i, num;

    // ...

  5. #80
    Junior Member
    Join Date
    Sep 2016
    Posts
    16
    Yes I have added the kinetis_hsrun_disable / _enable from the PJRC code to the code of FrankB, so it is nearly the same code. For me the goal is to get an unique mac address and also an UUID (RFC4122), I have to work on next.

  6. #81
    Junior Member
    Join Date
    Sep 2016
    Posts
    16
    Quote Originally Posted by defragster View Post
    Glancing at the code it looks like it has FrankB's work to get serial # before hsrun_disable was introduced for T_3.6 - that catching it in startup. Though that code is also there? The core of the code needs only do the work below to get the Serial #.

    The PJRC code to set the Serial Number is here: teensy3/usb_desc.c#L1294
    So, when I really understood, you mean that this part of the code can deleted!?

    Code:
    #if defined(HAS_KINETIS_FLASH_FTFE) && (F_CPU > 120000000)
    
    	extern "C" void startup_early_hook(void) {
    		#if defined(KINETISK)
      		WDOG_STCTRLH = WDOG_STCTRLH_ALLOWUPDATE;
    		#elif defined(KINETISL)
      		SIM_COPC = 0;  // disable the watchdog
    		#endif
    		*(uint32_t*)(MY_SYSREGISTERFILE) = _getserialhw();
    		}

  7. #82
    Senior Member defragster's Avatar
    Join Date
    Feb 2015
    Posts
    4,386
    Yes, that is the part that caught my eye. If that was indeed from the Beta posting - it was to get the SN before the hsrun state was entered and that value went 'offline'

  8. #83
    Junior Member
    Join Date
    Sep 2016
    Posts
    16
    Quote Originally Posted by defragster View Post
    Yes, that is the part that caught my eye. If that was indeed from the Beta posting - it was to get the SN before the hsrun state was entered and that value went 'offline'
    Thank you for your advices, I have rewritten and optimized the code and published it. Also added a UUID (RFC4122) function.

  9. #84
    Senior Member
    Join Date
    Nov 2012
    Location
    Salt Lake City, UT, USA
    Posts
    213

    TeensyID now tested on Teensy 3.2, example added

    Quote Originally Posted by sstaub View Post
    I have made a new library called TeensID based on the TeensyMAC lib from frank.
    You can find it at https://github.com/sstaub/TeensyID
    I have extended the library with pointers and strings for MAC, USB#, Serial# and ChipID
    It is only tested for Teensy 3.5
    I forked your repo, fixed a decl in the example code, made an Arduino library example folder, tested on T3.2, added to the readme, and issued a pull request. Here is output with T3.2:
    USB Serialnumber: 1244570
    Array Serialnumber: 00-01-E6-29
    String Serialnumber: 00-01-e6-29
    Array MAC Address: 04:E9:E5:01:E6:29
    String MAC Address: 04:e9:e5:01:e6:29
    Array 128-bit UniqueID from chip: C7210000-714D001E-00496017-31384E45
    String 128-bit UniqueID from chip: c7210000-714d001e-00496017-31384e45
    Array 128-bit UUID RFC4122: 00496017-3138-404E-8045-04E9E501E629
    String 128-bit UUID RFC4122: 00496017-3138-404e-8045-04e9e501e629
    Last edited by bboyes; 02-28-2017 at 07:10 PM.

  10. #85
    Senior Member manitou's Avatar
    Join Date
    Jan 2013
    Posts
    955
    Quote Originally Posted by sstaub View Post
    I have made a new library called TeensID based on the TeensyMAC lib from frank.
    You can find it at https://github.com/sstaub/TeensyID
    I have extended the library with pointers and strings for MAC, USB#, Serial# and ChipID
    It is only tested for Teensy 3.5
    tested on T3.6 and LC. ok

  11. #86
    Junior Member
    Join Date
    Sep 2016
    Posts
    16
    I have done a new release v1.1.1 with the pull request from bboyes. Thanks for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •