Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Busy in getting busier

Ravi Kumar Prasad ravikp7

🎯
Busy in getting busier
View GitHub Profile
@ravikp7
ravikp7 / README.md
Last active March 8, 2017 18:43 — forked from jadonk/README.md
Hacks and node-beaglebone-boot
View README.md

Current status:

playdoh:BBBlfs jason$ node --version
v7.5.0
playdoh:BBBlfs jason$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.38)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
@ravikp7
ravikp7 / U boot cross compile
Created March 7, 2017 04:49
Demonstrating Cross compilation of u boot for beagleblack
View U boot cross compile
ravi@ravi-Lenovo-G50-45:~/my-dev$ git clone git://git.denx.de/u-boot.git
Cloning into 'u-boot'...
remote: Counting objects: 450183, done.
remote: Compressing objects: 100% (81000/81000), done.
remote: Total 450183 (delta 367578), reused 444431 (delta 362074)
Receiving objects: 100% (450183/450183), 94.70 MiB | 578.00 KiB/s, done.
Resolving deltas: 100% (367578/367578), done.
Checking connectivity... done.
ravi@ravi-Lenovo-G50-45:~/my-dev$ cd u-boot/
ravi@ravi-Lenovo-G50-45:~/my-dev/u-boot$ ls
@ravikp7
ravikp7 / main.js
Created May 27, 2017 16:37
Testing parsing
View main.js
var usb = require('usb');
var Parser = require('binary-parser').Parser;
// Connect to BeagleBone
var device = usb.findByIds(0x0451, 0x6141);
//console.log(device);
device.open();
var interface = device.interface(1);
@ravikp7
ravikp7 / main.c
Last active May 27, 2017 16:41
checking bootp packet
View main.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libusb.h>
#include <linux/ip.h>
#include <unistd.h>
#include <sys/stat.h>
#include "rndis.h"
#include "ether2.h"
@ravikp7
ravikp7 / output
Created June 2, 2017 09:50
parsing test
View output
ravi@ravi-Lenovo-G50-45:~/beagle-js$ node serializer
<Buffer 06 ff ff ff ff ff ff 08 00 06 a0 f6 fd 8a e9 1a>
{ h_dest: [ 6, 255, 255, 255, 255, 255 ],
h_source: [ 255, 8, 0, 6, 160, 246 ],
h_proto: -630 }
@ravikp7
ravikp7 / output
Created June 4, 2017 05:32
Schemapack encoding doesn't work for array of more than 9 objects.
View output
ravi@ravi-Lenovo-G50-45:~/beagle-js$ node serializer-test.js
undefined:3
var ref1=json;var ref2=ref1['a'];var ref3=ref2[0];var ref4=ref2[1];var ref5=ref2[10];var ref6=ref2[2];var ref7=ref2[3];var ref8=re
f2[4];var ref9=ref2[5];var ref10=ref2[6];var ref11=ref2[7];var ref12=ref2[8];var byteC=0;byteC+=1;byteC+=1;byteC+=bag.dynamicByteC
ounts['string'](ref5['pad']);byteC+=1;byteC+=1;byteC+=1;byteC+=1;byteC+=1;byteC+=1;byteC+=1;byteC+=bag.getVarUIntByteLength(ref2.l
ength);for (var j2=10;j2<ref2.length;j2++) { var ref13xn=ref2[j2];byteC+=1;}var wBuffer=bag.allocUnsafe(byteC);bag.byteOffset=0;if
(typeof(ref3['a']) !== 'number'||ref3['a']<0||ref3['a']>255){bag.throwTypeError(ref3['a'],'number',0,255,'uint8');}bag.byteOffset
= wBuffer.writeUInt8(ref3['a'], bag.byteOffset, true);if (typeof(ref4['b']) !== 'number'||ref4['b']<0||ref4['b']>255){bag.throwTy
peError(ref4['b'],'number',0,255,'uint8');}bag.byteOffset = wBuffer.writeUInt8(ref4['b'], bag.byteOffset, true);if (typeof(ref5['p
ad']) !== 'string'){bag.throwTypeE
@ravikp7
ravikp7 / download.js
Created March 27, 2018 15:56
beaglebone latest images fetch
View download.js
var fs = require('fs')
var http = require('http')
var file = fs.createWriteStream("file.html");
var request = http.get("http://beagleboard.org/latest-images", function(response) {
response.pipe(file);
});
@ravikp7
ravikp7 / index.js
Created May 14, 2018 15:38
beagleboot adapter
View index.js
'use strict'
const EventEmitter = require('events')
const BeagleBoot = require('beagle-boot')
class BeagleBootAdapter extends EventEmitter {
/**
* @summary USBBootAdapter constructor
* @class
* @example
@ravikp7
ravikp7 / index.js
Created June 3, 2018 17:01
node-usb BeagleBone
View index.js
const usb = require('usb');
const device = usb.findByIds(0x1d6b, 0x0104);
device.open();
for (let i = 0; i < 7; i++) {
let devInt = device.interface(i);
if (devInt.isKernelDriverActive()) devInt.detachKernelDriver();
devInt.claim();
}
device.interfaces.forEach((interfac) => {
console.log(interfac);
@ravikp7
ravikp7 / async.js
Created May 14, 2019 15:16
Comparing different async JS styles
View async.js
// A library
const getImage = (url, callback) => {};
const imageUrls = [];
// Callback
/**
* This callback style code is least readable.
* It has trust issue as we depend upon getImage library to execute our callback.
* There may be a bug in the library and it may never run the callback