RocketLogger  1.1.6
web.c File Reference
#include <stdint.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include "pru.h"
#include "sem.h"
#include "types.h"
#include "web.h"
+ Include dependency graph for web.c:

Go to the source code of this file.

Functions

struct web_shmweb_create_shm (void)
 
struct web_shmweb_open_shm (void)
 
void web_buffer_reset (struct ringbuffer *buffer, int element_size, int length)
 
void web_buffer_add (struct ringbuffer *buffer, int64_t *data)
 
int64_t * web_buffer_get (struct ringbuffer *buffer, int num)
 
void web_merge_currents (uint8_t *valid, int64_t *dest, int64_t *src, struct rl_conf *conf)
 
void web_handle_data (struct web_shm *web_data_ptr, int sem_id, void *buffer_addr, uint32_t sample_data_size, uint32_t samples_count, struct time_stamp *timestamp_realtime, struct rl_conf *conf)
 

Function Documentation

void web_buffer_add ( struct ringbuffer buffer,
int64_t *  data 
)

Add element to ring buffer

Parameters
bufferPointer to ring buffer
dataPointer to data array to add

Definition at line 113 of file web.c.

References ringbuffer::data, ringbuffer::element_size, ringbuffer::filled, ringbuffer::head, and ringbuffer::length.

Referenced by web_handle_data().

int64_t* web_buffer_get ( struct ringbuffer buffer,
int  num 
)

Get pointer to a specific element of a ringbuffer

Parameters
bufferPointer to ring buffer
numElement number (0 corresponds to the newest element)
Returns
pointer to desired element

Definition at line 129 of file web.c.

References ringbuffer::data, ringbuffer::element_size, ringbuffer::head, and ringbuffer::length.

Referenced by print_data().

void web_buffer_reset ( struct ringbuffer buffer,
int  element_size,
int  length 
)

Reset web data ring buffer

Parameters
bufferPointer to ring buffer to reset
element_sizeDesired element size in bytes
lengthBuffer length in elements

Definition at line 101 of file web.c.

References ringbuffer::element_size, ringbuffer::filled, ringbuffer::head, and ringbuffer::length.

Referenced by pru_sample().

struct web_shm* web_create_shm ( void  )

Copyright (c) 2016-2019, Swiss Federal Institute of Technology (ETH Zurich) All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Create shared memory for data exchange with web server

Returns
pointer to shared memory, NULL in case of failure

Definition at line 47 of file web.c.

References ERROR, rl_log(), SHMEM_DATA_KEY, SHMEM_PERMISSIONS, and web_data.

Referenced by pru_sample().

+ Here is the call graph for this function:

void web_handle_data ( struct web_shm web_data_ptr,
int  sem_id,
void *  buffer_addr,
uint32_t  sample_data_size,
uint32_t  samples_count,
struct time_stamp timestamp_realtime,
struct rl_conf conf 
)

Process the data buffer for the web interface

Parameters
web_data_ptrPointer to shared web data
sem_idID of semaphores for shared web data
buffer_addrPointer to buffer to handle
sample_data_sizeSize of samples to read
samples_countNumber of samples to read
timestamp_realtimetime_stamp with realtime clock value
confCurrent rl_conf configuration.

Definition at line 201 of file web.c.

References BINARY_MASK, BUF100_INDEX, BUF10_INDEX, BUF1_INDEX, web_shm::buffer, BUFFER100_SIZE, BUFFER10_SIZE, BUFFER1_SIZE, calibration, CHANNEL_ENABLED, rl_conf::channels, count_channels(), DATA_SEM, rl_conf::digital_inputs, DIGITAL_INPUTS_ENABLED, rl_conf::enable_web_server, I1L_INDEX, I2L_INDEX, time_stamp::nsec, num_channels, web_shm::num_channels, NUM_CHANNELS, NUM_DIGITAL_INPUTS, NUM_I_CHANNELS, rl_calibration::offsets, PRU_DIG_SIZE, rl_log(), RL_RUNNING, rl_calibration::scales, time_stamp::sec, SEM_WRITE_TIME_OUT, set_sem(), rl_status::state, status, web_shm::time, TIME_OUT, VALID_MASK, wait_sem(), WARNING, web_buffer_add(), web_data, web_merge_currents(), and WEB_RING_BUFFER_COUNT.

Referenced by pru_sample().

+ Here is the call graph for this function:

void web_merge_currents ( uint8_t *  valid,
int64_t *  dest,
int64_t *  src,
struct rl_conf conf 
)

Merge high/low currents for web interface

Parameters
validValid information of low range current channels
destPointer to destination array
srcPointer to source array
confPointer to current rl_conf configuration

Definition at line 143 of file web.c.

References CHANNEL_ENABLED, rl_conf::channels, H_L_SCALE, I1H_INDEX, I1L_INDEX, I2H_INDEX, I2L_INDEX, V1_INDEX, V2_INDEX, V3_INDEX, and V4_INDEX.

Referenced by web_handle_data().

struct web_shm* web_open_shm ( void  )

Open existing shared memory for data exchange with web server

Returns
pointer to shared memory, NULL in case of failure

Definition at line 73 of file web.c.

References ERROR, rl_log(), SHMEM_DATA_KEY, SHMEM_PERMISSIONS, and web_data.

Referenced by main().

+ Here is the call graph for this function: