Changeset 6001:872d916b8ca0 in roaraudio
- Timestamp:
- 04/06/14 07:00:26 (10 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroarlight/roardmx.h
r5976 r6001 99 99 #define ROAR_ROARDMX_EVENT_USER15 0x3F /* User defined event #15 */ 100 100 101 /* subcommands for ROAR_ROARDMX_TYPE_CONTROL: */ 102 #define ROAR_ROARDMX_CTL_VERSION 0x00 /* Version of Codec */ 103 #define ROAR_ROARDMX_CTL_SYNC 0x01 /* Sync state */ 104 105 /* Flags for ROAR_ROARDMX_CTL_SYNC: */ 106 #define ROAR_ROARDMX_SYNC_DIRTY 0x01 /* global state is not sync, some more data needs to be send first */ 107 #define ROAR_ROARDMX_SYNC_CLEAN 0x02 /* global state is sync */ 108 #define ROAR_ROARDMX_SYNC_SOF 0x03 /* start of frame */ 109 #define ROAR_ROARDMX_SYNC_EOF 0x04 /* end of frame */ 110 #define ROAR_ROARDMX_SYNC_CLOCK 0x80 /* clock tick */ 111 101 112 // Data format on the wire: 102 113 /* … … 130 141 * (beat, on, off, hold) and the lower 6 bits to the type of te event. 131 142 * 132 * CONTROL: not implemented. 143 * CONTROL: transmit other control information. 144 * The body consists of a version byte followed by a command byte. 145 * The version byte is always zero by this standard. 146 * The command byte is one of ROAR_ROARDMX_CTL_* 147 * The rest of body depends on both the version and command byte. 148 * For command=VERSION packets the rest of the body is a single byte with the value 149 * of zero as of this standard. 150 * For command=SYNC packets the rest of the body is a single byte which is a bitarray 151 * for flags defined above as ROAR_ROARDMX_SYNC_*. 133 152 */ 134 153 … … 191 210 192 211 // * CONTROL: 193 // Not yet supported. 212 int roar_roardmx_message_new_version(struct roar_roardmx_message * mes, uint8_t version); 213 int roar_roardmx_message_new_sync(struct roar_roardmx_message * mes, uint8_t flags); 214 int roar_roardmx_message_get_subcommand(struct roar_roardmx_message * mes); 215 int roar_roardmx_message_get_ctl_version(struct roar_roardmx_message * mes); 216 int roar_roardmx_message_get_ctl_flags(struct roar_roardmx_message * mes); 194 217 195 218 #endif -
libroarlight/roardmx.c
r5978 r6001 561 561 562 562 // * CONTROL: 563 // Not yet supported. 563 static inline int roar_roardmx_message_new_control(struct roar_roardmx_message * mes, uint8_t subcommand) { 564 BCHK(mes); 565 566 if ( roar_roardmx_message_new(mes) == -1 ) 567 return -1; 568 569 mes->type = ROAR_ROARDMX_TYPE_CONTROL; 570 mes->data[3] = 0; // version 571 mes->data[4] = subcommand; 572 mes->length = 2; 573 574 return 0; 575 } 576 577 int roar_roardmx_message_new_version(struct roar_roardmx_message * mes, uint8_t version) { 578 BCHK(mes); 579 580 if ( version != (uint8_t)0 ) { 581 roar_err_set(ROAR_ERROR_NSVERSION); 582 return -1; 583 } 584 585 if ( roar_roardmx_message_new_control(mes, ROAR_ROARDMX_CTL_VERSION) == -1 ) 586 return -1; 587 588 mes->data[5] = version; 589 mes->length = 3; 590 591 return 0; 592 } 593 594 int roar_roardmx_message_new_sync(struct roar_roardmx_message * mes, uint8_t flags) { 595 BCHK(mes); 596 597 if ( roar_roardmx_message_new_control(mes, ROAR_ROARDMX_CTL_VERSION) == -1 ) 598 return -1; 599 600 mes->data[5] = flags; 601 mes->length = 3; 602 603 return 0; 604 } 605 606 int roar_roardmx_message_get_subcommand(struct roar_roardmx_message * mes) { 607 BCHK(mes); 608 609 if ( mes->type != ROAR_ROARDMX_TYPE_CONTROL ) { 610 roar_err_set(ROAR_ERROR_TYPEMM); 611 return -1; 612 } 613 614 if ( mes->length < 2 ) { 615 roar_err_set(ROAR_ERROR_PROTO); 616 return -1; 617 } 618 619 if ( mes->data[3] != 0 ) { 620 roar_err_set(ROAR_ERROR_NSVERSION); 621 return -1; 622 } 623 624 return mes->data[4]; 625 } 626 627 static inline int roar_roardmx_message_get_ctl_byte5(struct roar_roardmx_message * mes, uint8_t subtype) { 628 BCHK(mes); 629 630 if ( mes->type != ROAR_ROARDMX_TYPE_CONTROL ) { 631 roar_err_set(ROAR_ERROR_TYPEMM); 632 return -1; 633 } 634 635 if ( roar_roardmx_message_get_subcommand(mes) != (int)(unsigned)subtype ) { 636 roar_err_set(ROAR_ERROR_TYPEMM); 637 return -1; 638 } 639 640 return mes->data[5]; 641 } 642 643 int roar_roardmx_message_get_ctl_version(struct roar_roardmx_message * mes) { 644 return roar_roardmx_message_get_ctl_byte5(mes, ROAR_ROARDMX_CTL_VERSION); 645 } 646 647 int roar_roardmx_message_get_ctl_flags(struct roar_roardmx_message * mes) { 648 return roar_roardmx_message_get_ctl_byte5(mes, ROAR_ROARDMX_CTL_SYNC); 649 } 564 650 565 651 //ll
Note: See TracChangeset
for help on using the changeset viewer.