Changeset 5975:d856dad45320 in roaraudio


Ignore:
Timestamp:
01/27/14 16:22:27 (5 years ago)
Author:
phi
Branch:
default
Message:

Added support for rangeset to libroarlight.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5972 r5975  
    11v. 1.0beta12 - ? 
    22        * Added user defined RoarDMX events. 
     3        * Added support for rangeset to libroarlight. 
    34 
    45v. 1.0beta11 - Tue Jan 21 2014 21:04 CET 
  • include/libroarlight/roardmx.h

    r5972 r5975  
    120120 * IPO4: not implemented. 
    121121 * INC8S: not implemented. 
    122  * RANGESET: not implemented. 
     122 * RANGESET: Sets ranges of channels. 
     123 *  The body consists of {start, stop, value}-trippels. 
     124 *  Every entry is 5 byte: hi byte of start channel, low byte of start channel, 
     125 *  hi byte of end channel, low byte of end channel and value. 
     126 * 
    123127 * EVENT: transmit simple yet abstract events. 
    124128 * The body is an array of bytes. Each byte represents one event. 
     
    162166// Data/high level: 
    163167// * *: 
    164 int roar_roardmx_message_numchannels(struct roar_roardmx_message * mes); 
     168int roar_roardmx_message_numchannels(struct roar_roardmx_message * mes); // also works for rangesets 
    165169int roar_roardmx_message_add_chanval(struct roar_roardmx_message * mes, uint16_t   channel, unsigned char   val); 
    166170int roar_roardmx_message_get_chanval(struct roar_roardmx_message * mes, uint16_t * channel, unsigned char * val, int index); 
     
    176180// Not yet supported. 
    177181// * RANGESET: 
    178 // Not yet supported. 
     182int roar_roardmx_message_new_rangeset(struct roar_roardmx_message * mes); 
     183int roar_roardmx_message_add_rangeval(struct roar_roardmx_message * mes, uint16_t   start, uint16_t   end, unsigned char   val); 
     184int roar_roardmx_message_get_rangeval(struct roar_roardmx_message * mes, uint16_t * start, uint16_t * end, unsigned char * val, int index); 
     185 
    179186// * EVENT: 
    180187int roar_roardmx_message_new_event(struct roar_roardmx_message * mes); 
  • libroarlight/roardmx.c

    r5972 r5975  
    427427// Not yet supported. 
    428428// * RANGESET: 
    429 // Not yet supported. 
     429int roar_roardmx_message_new_rangeset(struct roar_roardmx_message * mes) { 
     430 BCHK(mes); 
     431 
     432 if ( roar_roardmx_message_new(mes) == -1 ) 
     433  return -1; 
     434 
     435 mes->type = ROAR_ROARDMX_TYPE_SSET; 
     436 
     437 return 0; 
     438} 
     439 
     440int roar_roardmx_message_add_rangeval(struct roar_roardmx_message * mes, uint16_t   start, uint16_t   end, unsigned char   val) { 
     441 register uint8_t * p; 
     442 
     443 BCHK(mes); 
     444 
     445 if ( mes->type != ROAR_ROARDMX_TYPE_RANGESET ) { 
     446  roar_err_set(ROAR_ERROR_TYPEMM); 
     447  return -1; 
     448 } 
     449 
     450 if ( (mes->length + 5) > ROAR_ROARDMX_DATA_LENGTH ) { // message would be to long 
     451  roar_err_set(ROAR_ERROR_NOSPC); 
     452  return -1; 
     453 } 
     454 
     455 p = mes->data + 3 + mes->length; 
     456 
     457 p[0] = (start & 0xFF00) >> 8; 
     458 p[1] = (start & 0x00FF); 
     459 p[2] = (end   & 0xFF00) >> 8; 
     460 p[3] = (end   & 0x00FF); 
     461 p[4] = val; 
     462 
     463 mes->length += 5; 
     464 
     465 return 0; 
     466} 
     467 
     468int roar_roardmx_message_get_rangeval(struct roar_roardmx_message * mes, uint16_t * start, uint16_t * end, unsigned char * val, int index) { 
     469 register uint8_t * p; 
     470 register uint16_t v; 
     471 
     472 BCHK(mes); 
     473 
     474 if ( index < 0 ) { 
     475  roar_err_set(ROAR_ERROR_INVAL); 
     476  return -1; 
     477 } 
     478 
     479 if ( mes->version != ROAR_ROARDMX_VERSION ) { 
     480  roar_err_set(ROAR_ERROR_NSVERSION); 
     481  return -1; 
     482 } 
     483 
     484 if ( mes->type != ROAR_ROARDMX_TYPE_RANGESET ) { 
     485  roar_err_set(ROAR_ERROR_TYPEMM); 
     486  return -1; 
     487 } 
     488 
     489 if ( (((size_t)index + 1) * 5) > (mes->length - 3) ) { 
     490  roar_err_set(ROAR_ERROR_NOENT); 
     491  return -1; 
     492 } 
     493 
     494 p = mes->data + 3 + index * 5;  
     495 
     496 v   = *(p++); 
     497 v <<= 8; 
     498 v  += *(p++); 
     499 *start = v; 
     500 
     501 v   = *(p++); 
     502 v <<= 8; 
     503 v  += *(p++); 
     504 *end = v; 
     505 
     506 *val = *p; 
     507 
     508 return 0; 
     509} 
     510 
    430511// * EVENT: 
    431512int roar_roardmx_message_new_event(struct roar_roardmx_message * mes) { 
Note: See TracChangeset for help on using the changeset viewer.