Skip to content
Snippets Groups Projects
Select Git revision
  • b11bd2ab79e0b58035e3205c6f87802d1076cde3
  • master default
  • labcomm2014
  • labcomm2006
  • python_sig_hash
  • typedefs
  • anders.blomdell
  • typeref
  • pragma
  • compiler-refactoring
  • labcomm2013
  • v2014.6
  • v2015.0
  • v2014.5
  • v2014.4
  • v2006.0
  • v2014.3
  • v2014.2
  • v2014.1
  • v2014.0
  • v2013.0
21 results

labcomm2006_encoder.c

Blame
  • labcomm2006_encoder.c 5.05 KiB
    /*
      labcomm2006_encoder.c -- handling encoding of labcomm samples.
    
      Copyright 2006-2013 Anders Blomdell <anders.blomdell@control.lth.se>
    
      This file is part of LabComm.
    
      LabComm is free software: you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
      the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.
    
      LabComm is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.
    
      You should have received a copy of the GNU General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
    */
    #include <errno.h>
    #include "labcomm2006.h"
    #include "labcomm2006_private.h"
    #include "labcomm2006_ioctl.h"
    
    struct labcomm2006_encoder {
      struct labcomm2006_writer *writer;
      struct labcomm2006_error_handler *error;
      struct labcomm2006_memory *memory;
      struct labcomm2006_scheduler *scheduler;
      LABCOMM_SIGNATURE_ARRAY_DEF(registered, int);
    };
    
    struct labcomm2006_encoder *labcomm2006_encoder_new(
      struct labcomm2006_writer *writer,
      struct labcomm2006_error_handler *error,
      struct labcomm2006_memory *memory,
      struct labcomm2006_scheduler *scheduler)
    {
      struct labcomm2006_encoder *result;
    
      result = labcomm2006_memory_alloc(memory, 0, sizeof(*result));
      if (result) {
        result->writer = writer;
        result->writer->encoder = result;
        result->writer->data = NULL;
        result->writer->data_size = 0;
        result->writer->count = 0;
        result->writer->pos = 0;
        result->writer->error = 0;
        result->error = error;
        result->memory = memory;
        result->scheduler = scheduler;
        LABCOMM_SIGNATURE_ARRAY_INIT(result->registered, int);
        labcomm2006_writer_alloc(result->writer,
    			 result->writer->action_context);
      }
      return result;
    }
    
    void labcomm2006_encoder_free(struct labcomm2006_encoder* e)
    {
      struct labcomm2006_memory *memory = e->memory;
    
      labcomm2006_writer_free(e->writer, e->writer->action_context);
      LABCOMM_SIGNATURE_ARRAY_FREE(e->memory, e->registered, int);
      labcomm2006_memory_free(memory, 0, e);
    }
    
    int labcomm2006_internal_encoder_register(