Skip to content

Instantly share code, notes, and snippets.

View reinzor's full-sized avatar
🤖

Rein Appeldoorn reinzor

🤖
View GitHub Profile
@reinzor
reinzor / signaldecode.c
Last active February 17, 2016 07:18
Decode CAN signals
#include <stdint.h>
#include <iostream>
#define MASK32(nbits) ((0xffffffff)>> (32-nbits))
uint32_t extractSignal(const uint8_t* frame, const uint8_t startbit, const uint8_t length, bool is_big_endian)
{
uint8_t startByte = startbit / 8;
uint8_t startbit_in_byte = startbit % 8;
uint8_t end_byte = 0;
@reinzor
reinzor / extract_can_signal.cpp
Last active February 15, 2016 11:51
Extract can frame data signal
#define MASK32(nbits) ((0xffffffff)>> (32-nbits))
uint32_t extractSignal(uint8_t* frame, uint8_t startbit, uint8_t length, bool is_big_endian)
{
uint8_t startByte = startbit/8;
uint8_t startBitInByte = startbit % 8;
uint8_t endByte = 0;
uint8_t count = 0;
uint8_t target = frame[startByte] >> startBitInByte;
uint8_t currentTargetLength = (8-startBitInByte);
PS1='[\[\033[01;34m\]\w\[\033[00m\]] $(__git_ps1 "(%s)") \n\$ '