Skip to content

Instantly share code, notes, and snippets.

View Julio-Guerra's full-sized avatar
👾

Julio Guerra Julio-Guerra

👾
View GitHub Profile
// Example of a function returning the json marshaling result of the
// given argument.
//
// This function is instrumented with a hook point example implementing
// the monitoring and protection control flow we need by observing function
// calls and possibly aborting them.
//
// To do so, the following instrumentation block of code is made of two parts:
//
// 1. The prolog: it is the instrumentation starting point and is a function
@Julio-Guerra
Julio-Guerra / bug.sh
Created August 20, 2016 03:11
cdc_acm buffer read problem
#!/bin/bash
set -e
: ${1?"missing argument 1: device node (e.g. /dev/ttyAMC0)"}
dev=$1
stty -F $dev 9600 raw min 8
# open the device once, with file descriptor 4
@Julio-Guerra
Julio-Guerra / README.md
Last active August 19, 2016 19:59
KMTronic FTDI USB-Serial out of sync test case

Content

U2CR test-case:

  • test.sh: test running P1 and P2 interleaved until the error is detected.
  • p1.sh: process P1 which creates problems.
  • p2.sh: process P2 which detect the problem.

Description

Process 1 p1.sh:

    1. Send a status request, like "\xff\x01\x03"
    1. Do not read the answer.
@Julio-Guerra
Julio-Guerra / usb.c
Created June 1, 2016 11:19
USB Control Message to flush a FTDI device without detaching the ftdi_sio kernel driver Raw
// gcc -I/usr/include/libftdi1 -I/usr/include/libusb-1.0 usb.c
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>
#include <asm/byteorder.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@Julio-Guerra
Julio-Guerra / test.c
Last active June 1, 2016 11:18
pty in blocking mode with buf <= rx < min
// compilation: gcc -D_GNU_SOURCE -O0 -g -ggdb test.c
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <termios.h>
#include <unistd.h>
#include <assert.h>
#define TEST_VMIN 5
[ upgrade.ini ]
lastUpgradeInfo trigger="" time=0001-01-01T00:00:00Z error="No error"
config trace_level=2 acsContactTimeout=5
[ sntpc.ini ]
config state=disabled poll=60 pollpresync=5 wanSubscribe=enabled
debug traceconfig state=disabled
[ xdsl.ini ]
debug traceconfig level=0
@Julio-Guerra
Julio-Guerra / pareto.sql
Last active October 5, 2015 08:38
TSQL Pareto's Distribution
-- Get the distribution of activity percentage among resources (Pareto's curve point)
-- This query uses abstract tables :
-- Activity(activity_id, resource_id) representing a sale, or a meeting, or a call...
-- Resource(resource_id) representing the resource used to make activities (a rep, or a product...)
SELECT
groups.resource_percentage,
sum(customer_calls_percentage.activity_percentage) AS activity_percentage
FROM
(
@Julio-Guerra
Julio-Guerra / main.adb
Created May 23, 2012 13:59
Separating "interface constants" (types, package renames & constants values) from the interface declaration in Ada using sibling packages
with Misc.Interface; use Misc.Interface;
with Misc.Types; use Misc.Types;
procedure Main is
X : A := A'(Bar); -- separate type definitions ok
begin
F(X);
F(Cst); -- separate constant values definitions ok
Rename_Me.Put_Line(A'Image(X)); -- separate package renames ok
end Main;
@Julio-Guerra
Julio-Guerra / main.adb
Created May 23, 2012 09:34
Static pipeline in Ada
-- Usage example
with Ada.Text_IO; use Ada.Text_IO;
with Pipeline;
procedure Main is
-- Pipeline functions
procedure Step1 is
begin
Put("1");
end Step1;