Ejemplo n.º 1
0
Archivo: logger.c Proyecto: mcu786/u
/**
 * Get id of data
 * Pack it
 * Store to FS buffer
 * Raise bool flag if fresh data available
 */
FRESULT WriteLog(FIL *Log, msg_t id, bool_t *fresh_data){
  uint32_t bytes_written;
  uint8_t *fs_buf;
  FRESULT err = FR_OK;

  mavencoder(id, mavlink_system_struct.sysid, &mavlink_msgbuf_log);

#if MAVLINK_LOG_FORMAT
#if CH_DBG_ENABLE_CHECKS
  /* fill buffer with zeros except the timestamp region. Probably not necessary */
  memset(recordbuf + TIME_LEN, 0, RECORD_LEN - TIME_LEN);
#endif
  uint64_t timestamp = pnsGetTimeUnixUsec();
  mavlink_msg_to_send_buffer(recordbuf + TIME_LEN, &mavlink_msgbuf_log);
  memcpy(recordbuf, &timestamp, TIME_LEN);
  fs_buf = bufferize(recordbuf, RECORD_LEN);
#else
  uint16_t len = 0;
  len = mavlink_msg_to_send_buffer(recordbuf, &mavlink_msgbuf_log);
  fs_buf = bufferize(recordbuf, len);
#endif

  if (fs_buf != NULL){
    err = f_write(Log, fs_buf, BUFF_SIZE, (void *)&bytes_written);
    if (err == FR_OK)
      *fresh_data = TRUE;
  }
  return err;
}
Ejemplo n.º 2
0
size_t	handle_string(t_printf_data parameters, va_list ap)
{
	const char	*value = va_arg(ap, char *);
	size_t		len = ft_strlen(value);

	if (parameters.width > len)
	{
		if (parameters.flags[ft_strchr(PARAMETERS, *LEFT_JUSTIFY) - PARAMETERS])
		{
			bufferize(value, len, 0);
			bufferize_char(' ', parameters.width - len, 0);
		}
		else
		{
			if (parameters.flags[ft_strchr(PARAMETERS, *PAD_ZERO) - PARAMETERS])
				bufferize_char('0', parameters.width - len, 0);
			else
				bufferize_char(' ', parameters.width - len, 0);
			bufferize(value, len, 0);
		}
	}
	else
		bufferize(value, len, 0);
	return (0);
}
Ejemplo n.º 3
0
// ---------------------------------------------------------------------------
// 
// ------------
void bXMapBuffer::bufferize(){
	_prm.tp=(bGenericType*)CurType(_gapp);
	if(!_prm.tp){
		return;
	}
bEventLog	log(_gapp,this);
	bufferize(_prm);
	log.close();
}
Ejemplo n.º 4
0
// ---------------------------------------------------------------------------
// 
// ------------
bool bXMapBuffer::process(int msg, void* prm){
	switch(msg){
		case kExtProcessCallFromIntf:
			bufferize();
			break;
		case kExtProcessCallWithParams:{
buffer_prm		p=(*((buffer_prm*)prm));
				bufferize(p);
			}
			break;
		case kExtProcessCallWithXMLTree:{
buffer_prm				p;
char					val[_values_length_max_];
bGenericXMLBaseElement*	elt;
				elt=getelement(1);
				if(!elt){
					return(false);
				}
				elt->getvalue(val);
				p.tp=_gapp->typesMgr()->get(_gapp->typesMgr()->index(val));
				if(!p.tp){
					return(false);
				}
				elt=getelement(2);
				if(!elt){
					return(false);
				}
				elt->getvalue(val);
				p.d=atof(val);
				
				bufferize(p);
				return(true);
			}	
			break;
		default:
			break;
	}
	return(true);
}
Ejemplo n.º 5
0
Archivo: mapedit2.c Proyecto: rj76/kq
void do_new_map (int x, int y, int tileset)
{

	/* This should go in another function */
	
   /* Default values for the new map */
   gmap.map_no = 0;
   gmap.zero_zone = 0;
   gmap.map_mode = 0;
   gmap.can_save = 0;
   gmap.tileset = tileset;
   gmap.use_sstone = 1;
   gmap.can_warp = 0;
   gmap.extra_byte = 0;
   gmap.xsize = x;
   gmap.ysize = y;
   gmap.pmult = 1;
   gmap.pdiv = 1;
   gmap.stx = 0;
   gmap.sty = 0;
   gmap.warpx = 0;
   gmap.warpy = 0;
   gmap.revision = 2;
   gmap.extra_sdword2 = 0;
   gmap.song_file[0] = 0;
   gmap.map_desc[0] = 0;
   gmap.num_markers = 0;
   gmap.markers = NULL;
   gmap.num_bound_boxes = 0;
   gmap.bound_box = NULL;

   active_bound = 0;
	/* */

	bufferize();
	load_iconsets(pal);
   convert_icons ();

   /* FIXME: load_map should do this */
   number_of_ents = 0;
   while (number_of_ents < 50 && gent[number_of_ents].active) {
      ++number_of_ents;
   }
}
Ejemplo n.º 6
0
bool
CBigramHistory::saveToFile(const char *fname)
{
    if (!fname)
        fname = m_history_path.c_str();

    bool suc = false;
    size_t sz = 0;
    void* buf = NULL;
    if (bufferize(&buf, &sz) && buf) {
        FILE* fp = fopen(fname, "wb");
        if (fp) {
            suc = (fwrite(buf, 1, sz, fp) == sz);
            fclose(fp);
        }
        free(buf);
    }
    return suc;
}
Ejemplo n.º 7
0
int			main(void)
{
	identify(build_board(bufferize()));
	return (0);
}