| 579 | | return setDeviceNickName(name); |
|---|
| | 579 | char namestring[DICE_NICK_NAME_SIZE+1]; |
|---|
| | 580 | strncpy(namestring, name.c_str(), DICE_NICK_NAME_SIZE); |
|---|
| | 581 | |
|---|
| | 582 | // Strings from the device are always little-endian, |
|---|
| | 583 | // so byteswap for big-endian machines |
|---|
| | 584 | #if __BYTE_ORDER == __BIG_ENDIAN |
|---|
| | 585 | byteSwapBlock((quadlet_t *)namestring, DICE_NICK_NAME_SIZE/4); |
|---|
| | 586 | #endif |
|---|
| | 587 | |
|---|
| | 588 | if (!writeGlobalRegBlock(DICE_REGISTER_GLOBAL_NICK_NAME, |
|---|
| | 589 | (fb_quadlet_t *)namestring, DICE_NICK_NAME_SIZE)) { |
|---|
| | 590 | debugError("Could not write nickname string \n"); |
|---|
| | 591 | return false; |
|---|
| | 592 | } |
|---|
| | 593 | return true; |
|---|
| 585 | | return getDeviceNickName(); |
|---|
| | 599 | char namestring[DICE_NICK_NAME_SIZE+1]; |
|---|
| | 600 | |
|---|
| | 601 | if (!readGlobalRegBlock(DICE_REGISTER_GLOBAL_NICK_NAME, |
|---|
| | 602 | (fb_quadlet_t *)namestring, DICE_NICK_NAME_SIZE)) { |
|---|
| | 603 | debugError("Could not read nickname string \n"); |
|---|
| | 604 | return std::string("(unknown)"); |
|---|
| | 605 | } |
|---|
| | 606 | |
|---|
| | 607 | // Strings from the device are always little-endian, |
|---|
| | 608 | // so byteswap for big-endian machines |
|---|
| | 609 | #if __BYTE_ORDER == __BIG_ENDIAN |
|---|
| | 610 | byteSwapBlock((quadlet_t *)namestring, DICE_NICK_NAME_SIZE/4); |
|---|
| | 611 | #endif |
|---|
| | 612 | namestring[DICE_NICK_NAME_SIZE]='\0'; |
|---|
| | 613 | return std::string(namestring); |
|---|
| 1557 | | std::string |
|---|
| 1558 | | Device::getDeviceNickName() { |
|---|
| 1559 | | char namestring[DICE_NICK_NAME_SIZE+1]; |
|---|
| 1560 | | |
|---|
| 1561 | | if (!readGlobalRegBlock(DICE_REGISTER_GLOBAL_NICK_NAME, |
|---|
| 1562 | | (fb_quadlet_t *)namestring, DICE_NICK_NAME_SIZE)) { |
|---|
| 1563 | | debugError("Could not read nickname string \n"); |
|---|
| 1564 | | return std::string("(unknown)"); |
|---|
| 1565 | | } |
|---|
| 1566 | | |
|---|
| 1567 | | // Strings from the device are always little-endian, |
|---|
| 1568 | | // so byteswap for big-endian machines |
|---|
| 1569 | | #if __BYTE_ORDER == __BIG_ENDIAN |
|---|
| 1570 | | byteSwapBlock((quadlet_t *)namestring, DICE_NICK_NAME_SIZE/4); |
|---|
| 1571 | | #endif |
|---|
| 1572 | | namestring[DICE_NICK_NAME_SIZE]='\0'; |
|---|
| 1573 | | return std::string(namestring); |
|---|
| 1574 | | } |
|---|
| 1575 | | |
|---|
| 1576 | | bool |
|---|
| 1577 | | Device::setDeviceNickName(std::string name) { |
|---|
| 1578 | | char namestring[DICE_NICK_NAME_SIZE+1]; |
|---|
| 1579 | | strncpy(namestring, name.c_str(), DICE_NICK_NAME_SIZE); |
|---|
| 1580 | | |
|---|
| 1581 | | // Strings from the device are always little-endian, |
|---|
| 1582 | | // so byteswap for big-endian machines |
|---|
| 1583 | | #if __BYTE_ORDER == __BIG_ENDIAN |
|---|
| 1584 | | byteSwapBlock((quadlet_t *)namestring, DICE_NICK_NAME_SIZE/4); |
|---|
| 1585 | | #endif |
|---|
| 1586 | | |
|---|
| 1587 | | if (!writeGlobalRegBlock(DICE_REGISTER_GLOBAL_NICK_NAME, |
|---|
| 1588 | | (fb_quadlet_t *)namestring, DICE_NICK_NAME_SIZE)) { |
|---|
| 1589 | | debugError("Could not write nickname string \n"); |
|---|
| 1590 | | return false; |
|---|
| 1591 | | } |
|---|
| 1592 | | return true; |
|---|
| 1593 | | } |
|---|
| 1594 | | |
|---|