Skip to content

Instantly share code, notes, and snippets.

View alexanderhiam's full-sized avatar
🐈

Alex Hiam alexanderhiam

🐈
View GitHub Profile
@alexanderhiam
alexanderhiam / rs485-test.c
Last active January 4, 2016 01:29
Both these tests are failing on the BeagleBone and BeagleBone Black...
#include <linux/serial.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#define TIOCGRS485 0x542E
#define TIOCSRS485 0x542F
int main(void) {
struct serial_rs485 rs485conf;
@alexanderhiam
alexanderhiam / cape-thermostat-00A0.dts
Last active August 29, 2015 13:57
Device Tree overlay and Python program for a simple thermostat BeagleBone cape: http://inspire.logicsupply.com/p/building-custom-cape.html
/* cape-thermostat-00A0.dts
* Mar. 2014
*
* Overlay for a simple thermostat cape.
*
* Created for Logic Supply's custom cape tutorial here:
* http://inspire.logicsupply.com/p/building-custom-cape.html
*/
/dts-v1/;
@alexanderhiam
alexanderhiam / dmx512.py
Created May 19, 2014 16:07
DMX512 demo for Logic Supply's CBB-Serial BeagleBone cape
"""
dmx512.py
May, 2014
Alexander Hiam <hiamalexander@gmail.com>
A very basic DMX512 implementation made for the BeagleBone and
BeagleBone Black.
DMX512 class should be instantiated with a PyBBIO serial port object,
e.g.:

SET

CMD   A     VALA     B     VALB  
0000 0000 0000 0000 0000 0000 0000 0000
\  / \  / \       / \  / \       / \  / 
SET  DIO      5     VAR      4   ignored
  • A,B are one of DIO, AO, PWM, TMR, user variable, value
root@beaglebone:~/pruspeak/src/driver# insmod ./pru_speak.ko
root@beaglebone:~/pruspeak/src/driver# lsmod | grep pru
pru_speak 22648 0
root@beaglebone:~/pruspeak/src/driver# ls /lib/firmware/ | grep pru
pru_firmware
root@beaglebone:~/pruspeak/src/driver# echo BB-BONE-PRU-07 > $SLOTS
root@beaglebone:~/pruspeak/src/driver# cat $SLOTS
0: 54:PF---
1: 55:PF---
2: 56:PF---
newid
4bc749bdf3c50b199945
4bc749bdf3c50b199945
4bc749bdf3c50b199945
4bc749bdf3c50b199945
4bc749bdf3c50b199945
4bc749bdf3c50b199945
4bc749bdf3c50b199945
@alexanderhiam
alexanderhiam / CARD_Preview.html
Created July 16, 2014 18:30
Bone101 Tutorial
<p>Hello, World!<br></p>
@alexanderhiam
alexanderhiam / CARD_Preview.html
Created July 16, 2014 18:42
Bone101 Tutorial
<p>Test<br></p>
@alexanderhiam
alexanderhiam / adc-sampling.pruspeak
Created July 18, 2014 14:01
pruspeak shared variable example
SCRIPT
SET period_ms, 100 // set inital value
SET ain_val, AIN[0]
WAIT period_ms
GOTO 1
ENDSCRIPT
// When it's running you can change the sampling period with:
SET period_ms, x
// and get the value with:
@alexanderhiam
alexanderhiam / rs485-ioctl.py
Last active April 23, 2020 20:48
Demonstrating the BeagleBone Black's Kernel driver working in RS485 mode with Michael Musset's gpio RTS patch
import serial, fcntl, struct, time
ser = serial.Serial(
port='/dev/ttyO4',
baudrate=9600,
timeout=1,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS
)