Skip to content

Instantly share code, notes, and snippets.

View tomeaton17's full-sized avatar

Tom Eaton tomeaton17

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main (void) {
srand(time(NULL));
int currentPosition[2] = {0,0};
int startRow = rand() / (RAND_MAX / (9 + 1) + 1);
int startColumn = rand() / (RAND_MAX / (9 + 1) + 1);
@tomeaton17
tomeaton17 / iptables.conf
Created August 7, 2018 00:52
Causing intermittent drop outs
# Generated by iptables-save v1.6.2 on Tue Aug 7 00:51:28 2018
*security
:INPUT ACCEPT [892816:236841925]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [903821:312132550]
COMMIT
# Completed on Tue Aug 7 00:51:28 2018
# Generated by iptables-save v1.6.2 on Tue Aug 7 00:51:28 2018
*raw
:PREROUTING ACCEPT [919852:238407317]
@tomeaton17
tomeaton17 / primes.cpp
Created August 6, 2018 22:30
to size_t or not to size_t?
bool is_prime(int number, vector<int> primes)
{
bool is_prime {true};
size_t counter {0};
while (is_prime && counter < primes.size()) {
if (number % primes[counter] == 0) {
is_prime = false;
}
++counter;
/*
Name: CurrentController.ino
Created: 5/23/2018 5:14:18 PM
Author: tomea
*/
#include <Servo.h>
#include "Battery.h"
#include <Wire.h>
#include <Adafruit_ADS1015.h>
@tomeaton17
tomeaton17 / Battery.cpp
Created May 24, 2018 15:53
Program hangs if line 24 of Battery.cpp is uncommented.
#include "Battery.h"
// Initilisation function for battery class.
// Params:
// float pdFactor - factor to convert divided voltage to actual voltage. Needs to be measured manually.
// int averagingWindow - How many samples to use when averaging
// int voltagePin - Pin number for reading voltage (Must be an analog pin)
// int currentPin - Pin number for reading current (Must be an analog pin)
Battery::Battery(float pdFactor, int averagingWindow, int voltagePin, int currentPin) : pdFactor(pdFactor), averagingWindow(averagingWindow), voltagePin(voltagePin), currentPin(currentPin) {
/*
Name: BatteryLogger.ino
Created: 5/14/2018 11:02:28 AM
Author: tomea
*/
#include <Servo.h>
Servo myServo;
const float PD_FACTOR = 3.504943957968f;
@tomeaton17
tomeaton17 / currentstep.py
Created May 15, 2018 16:24
Current stepper for EDF
import time, serial
from datetime import datetime
ser = serial.Serial('COM17')
time.sleep(10)
path = datetime.now().strftime('%Y-%m-%d-%H%M%S') + ".log"
file = open(path, 'w')
ser.write(b'S')
counter = 5
forwards = True
cmake_minimum_required (VERSION 2.6)
project(HawkCell)
set( CMAKE_EXPORT_COMPILE_COMMANDS ON )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
set(CMAKE_BUILD_TYPE Debug)
find_library(read_lib readline)
find_library(curses_lib ncurses)
find_library(pthread_lib pthread)
find_library(rt_lib rt)
find_package(Boost COMPONENTS system timer chrono)
execve("./HawkCell", ["./HawkCell"], [/* 25 vars */]) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/arm-linux-gnueabihf/libboost_system.so.1.58.0", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
#include <iostream>
#include <cstdlib>
#include <string>
#include<chrono>
#include<thread>
#include <boost/asio.hpp>
#include <boost/asio/serial_port.hpp>
using namespace std;