Changeset 5977:6b7d6fcf80b5 in roaraudio


Ignore:
Timestamp:
01/27/14 18:57:46 (6 years ago)
Author:
phi
Branch:
default
Message:

Added support for rangeset to roard and roarlight.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5975 r5977  
    11v. 1.0beta12 - ? 
    22        * Added user defined RoarDMX events. 
    3         * Added support for rangeset to libroarlight. 
     3        * Added support for rangeset to libroarlight, roard and roarlight. 
    44 
    55v. 1.0beta11 - Tue Jan 21 2014 21:04 CET 
  • libroarlight/roardmx.c

    r5975 r5977  
    433433  return -1; 
    434434 
    435  mes->type = ROAR_ROARDMX_TYPE_SSET; 
     435 mes->type = ROAR_ROARDMX_TYPE_RANGESET; 
    436436 
    437437 return 0; 
     
    487487 } 
    488488 
    489  if ( (((size_t)index + 1) * 5) > (mes->length - 3) ) { 
     489 if ( (((size_t)index + 1) * 5) > mes->length ) { 
     490  ROAR_DBG("roar_roardmx_message_get_rangeval(mes=%p{.length=%i, ...}, start=%p, end=%p, val=%p, index=%i) = ?", mes, (int)mes->length, start, end, val, index); 
    490491  roar_err_set(ROAR_ERROR_NOENT); 
    491492  return -1; 
  • roarclients/roarlight.c

    r5961 r5977  
    9595} 
    9696 
     97static int cmd_rangeset (char * arg) { 
     98 char * next = arg; 
     99 char * k, * v; 
     100 int32_t start, end, val; 
     101 struct roar_roardmx_message mes; 
     102 
     103 roar_roardmx_message_new_rangeset(&mes); 
     104 
     105 while (next != NULL) { 
     106  arg  = next; 
     107  next = strstr(next, ","); 
     108  if ( next != NULL ) { 
     109   *next = 0; 
     110    next++; 
     111  } 
     112 
     113  k = arg; 
     114  v = strstr(arg, "="); 
     115  if ( v == NULL ) 
     116   return -1; 
     117 
     118  *v = 0; 
     119   v++; 
     120 
     121  val  = atoi(v); 
     122 
     123  v = strstr(arg, "-"); 
     124  if ( v == NULL ) { 
     125   start = end = atoi(k); 
     126  } else { 
     127  *v = 0; 
     128   v++; 
     129   start = atoi(k); 
     130   end = atoi(v); 
     131  } 
     132 
     133//  printf("k='%s'(%i), v='%s'(%i)\n", k, chan, v, val); 
     134  if ( roar_roardmx_message_add_rangeval(&mes, start, end, val) == -1 ) { 
     135   return -1; 
     136  } 
     137 } 
     138 
     139 if ( roar_roardmx_message_send(&mes, g_stream) == -1 ) { 
     140  return -1; 
     141 } 
     142 
     143 return 0; 
     144} 
     145 
    97146static int cmd_event (char * arg) { 
    98147 struct roar_roardmx_message mes; 
     
    146195   i++; 
    147196   if ( cmd_sset(argv[i]) == -1 ) { 
     197    fprintf(stderr, "Error: can not set channels\n"); 
     198   } else { 
     199    printf("channels changed\n"); 
     200   } 
     201  } else if ( !strcmp(k, "rangeset") ) { 
     202   ROAR_CKHAVEARGS(1); 
     203   i++; 
     204   if ( cmd_rangeset(argv[i]) == -1 ) { 
    148205    fprintf(stderr, "Error: can not set channels\n"); 
    149206   } else { 
  • roard/codecfilter_roardmx.c

    r5961 r5977  
    5353} 
    5454 
     55static inline int __read_rangeset(int id, struct roar_stream_server * ss, struct roar_roardmx_message * mes) { 
     56 uint16_t start, end; 
     57 uint8_t value; 
     58 size_t p; 
     59 int i, c; 
     60 
     61 // we ignore errors here at the moment as 0 not < -1 
     62 c = roar_roardmx_message_numchannels(mes); 
     63 ROAR_DBG("__read_rangeset(id=%i, ...): Number of subframes: %u", id, c); 
     64 
     65 for (i = 0; i < c; i++) { 
     66  ROAR_DBG("__read_rangeset(id=%i, ...): i=%i", id, i); 
     67 
     68  if ( roar_roardmx_message_get_rangeval(mes, &start, &end, &value, i) == -1 ) { 
     69   ROAR_WARN("__read_rangeset(id=%i, ...): Can not read subframe: %i: %s", id, i, roar_errorstring); 
     70   return -1; 
     71  } 
     72 
     73  ROAR_DBG("__read_rangeset(id=%i, ...): i=%i, start=%u, end=%u, value=%u", id, i, start, end, value); 
     74 
     75  if ( start > end ) { 
     76   ROAR_WARN("__read_rangeset(id=%i, ...): Bad RoarDMX Rangeset frame: start > end.", id); 
     77   continue; 
     78  } 
     79 
     80  if ( g_light_state.channels < end ) { 
     81   ROAR_WARN("__read_rangeset(id=%i, ...): Range out of DMX universe: %u-%u", id, start, end); 
     82   continue; 
     83  } 
     84 
     85  for (p = start; p <= end; p++) { 
     86   g_light_state.state[p]   = value; 
     87   g_light_state.changes[p] = 0xFF; // the channel changed  
     88  } 
     89 } 
     90 
     91 return 0; 
     92} 
     93 
    5594static inline int __read_events(int id, struct roar_stream_server * ss, struct roar_roardmx_message * mes) { 
    5695 const uint8_t * events; 
     
    77116 switch (type) { 
    78117  case ROAR_ROARDMX_TYPE_SSET: return __read_sset(id, ss, &mes); break; 
     118  case ROAR_ROARDMX_TYPE_RANGESET: return __read_rangeset(id, ss, &mes); break; 
    79119  case ROAR_ROARDMX_TYPE_EVENT: return __read_events(id, ss, &mes); break; 
    80120 } 
Note: See TracChangeset for help on using the changeset viewer.