Verified Commit 5d8e05f0 authored by Isabella Skořepová's avatar Isabella Skořepová
Browse files

Software pro groundstation

parent 732d1553
*~
*.o
*.b#*
*.s#*
.mayaSwatches
*~
*.o
*.b#*
*.s#*
.mayaSwatches
CC=gcc
all: RAJSAT_decode
clean:
-rm RAJSAT_decode
-rm RAJSAT_decode.o
robot: RAJSAT_decode.o
$(CC) $() RAJSAT_decode.o -l c -o RAJSAT_decode $()
robot.o: RAJSAT_decode.c
#include <stdio.h>
#include <math.h>
// #include <stdlib.h>
// #include <time.h>
#include <unistd.h>
int crc16_update(int crc, char a)
{
int i;
crc ^= a;
for (i = 0; i < 8; ++i)
{
if (crc & 1)
crc = (crc >> 1) ^ 0xA001;
else
crc = (crc >> 1);
}
return crc;
}
int main(int argc, char** argv)
{
FILE *f_in , *f_out;
// lat lon alt sats pres temp id hum temp acc cam crc
char delka[] = { 24, 24, 14, 4, 14, 10, 17, 10, 10, 9, 2, 18};
double prepocet[] = { 0.00001,0.00001,1, 1, 10, 0.1, 1, 0.1, 0.1, 0.01, 1, 1};
char desetina_mista[] = { 5, 5, 0, 0, 0, 1, 0, 1, 1, 2, 0, 0};
char min8[] = { 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
char g = ~0;
long hodnoty[10];
char c = 0;
char d = 0;
long number = 0;
char i = 0;
char n = 0;
char j = 0;
char chyba = 0;
long radek;
int crc = 0xFFFF;
if(argc <= 1) {
f_in = fopen("/home/ondra/.fldigi/talk/textout.txt", "r");
} else {
f_in = fopen(argv[1], "r");
}
f_out = fopen("./data.txt", "w");
for(long limit=0;limit<1000;)
{
c = fgetc(f_in);
switch(c)
{
case '\n':
radek++;
// printf ("n = %d\n",n);
if ((n==sizeof(delka)) & (chyba==0))
{
// printf ("radek = %ld\n",radek);
for(j=0; j<sizeof(delka); j++)
{
printf ("%*.*f\t",min8[j],desetina_mista[j] ,hodnoty[j] * prepocet[j]);
fprintf (f_out,"%*.*f\t",min8[j],desetina_mista[j] ,hodnoty[j] * prepocet[j]);
}
if (hodnoty[sizeof(delka)-1] != crc)
{
printf ("!!!!!!!!!!!!!!!!");
fprintf (f_out,"!!!!!!!!!!!!!!!!");
}
// printf ("%d\t" ,crc);
printf ("\n");
fprintf (f_out,"\n");
}
i=0;
number = 0;
chyba = 0;
n=0;
crc = 0xFFFF;
continue;
// case '0':
// d=0;
// break;
// case '1':
// d=1;
// break;
// case '2':
// d=2;
// break;
// case '3':
// d=3;
// break;
// case '4':
// d=4;
// break;
// case '5':
// d=5;
// break;
// case '6':
// d=6;
// break;
// case '7':
// d=7;
// break;
// case '8':
// d=8;
// break;
// case '9':
// d=9;
// break;
// case 'A':
// d=10;
// break;
// case 'B':
// d=11;
// break;
// case 'C':
// d=12;
// break;
// case 'D':
// d=13;
// break;
// case 'E':
// d=14;
// break;
// case 'F':
// d=15;
// break;
case 0x21 ... 0x60:
d=c-0x21;
break;
case -1 :
usleep(200000);
// printf ("x\n");
continue;
default:
chyba = 1;
break;
}
if (chyba == 0)
{
if (n < sizeof(delka)-1)
{
crc = crc16_update(crc, c);
}
for(j=0;j<6;j++)
{
if ((d & 0x20) == 0)
{
number = (number << 1) ;
}
else
{
number = (number << 1) | 0x01;
}
d = d << 1;
i++;
if (n < sizeof(delka))
{
if (i >= delka[n])
{
hodnoty[n] = number;
n++;
i = 0;
number = 0;
}
}
else
{
chyba = 1;
}
}
}
}
}
4C80DA160521
4C80DA160521
4C80DA160521
# readme
Spouštěcí příkaz: `parser_dat_z_fldigi | node server/index.js`
This diff is collapsed.
{
"name": "rajsat-visualiser",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"express": "^4.15.2",
"minimist": "^1.2.0",
"socket.io": "^1.7.3"
},
"devDependencies": {}
}
<!DOCTYPE html>
<html>
<head>
<title>RAJsat3 is here!</title>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script src="/socket.io/socket.io.js"></script>
<style id="style"></style>
<style>
#map {
height: 95vh;
}
</style>
<script type="text/javascript">
var mapState = {}
var pos = {}
function initMap() {
mapState.map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 23,
});
mapState.infoWindow = new google.maps.InfoWindow({setMap: map});
if(pos.lat) {
setPos(pos.lat, pos.lng)
}
}
function setPos(lat, lng) {
pos.lat = lat
pos.lng = lng
if(!mapState.map) {
return
}
console.log("Setting pos",lat,lng)
mapState.infoWindow.setPosition(pos);
mapState.infoWindow.setContent('RAJsat3');
if(!mapState.marker) {
mapState.marker = new google.maps.Marker({
position: new google.maps.LatLng(pos.lat, pos.lng),
map: mapState.map,
});
} else {
mapState.marker.setPosition(new google.maps.LatLng(pos.lat, pos.lng));
}
mapState.map.setCenter(pos);
}
var chartNo = Number(window.location.search.substring(1))
var columns = [
"Tlak",
"Teplota",
"Vlhkost",
"Výška"
]
console.log({chartNo})
if(chartNo) {
document.getElementById('style').innerHTML = ".chart_div {height: 100vh; display: none}"
+ "\n#chart_div_"+(chartNo-1)+" {display: block}"
+ "\nbody { overflow: hidden }"
}
google.charts.load('current', { 'packages': ['corechart'] })
google.charts.setOnLoadCallback(drawChart)
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};
function subscribe(tables, redraw) {
var socket = io()
socket.on('connect', function () {
console.log('connected')
})
socket.on('init', function (data) {
const rows = data.data
console.log('init', rows)
for(var i = 0; i < columns.length; i++) {
var rowCount = tables[i].getNumberOfRows()
if(rowCount) tables[i].removeRows(rowCount)
tables[i].addRows(rows.map(function(row) {
return [row[0], row[i+1]]
}))
}
var p = rows[rows.length - 1]
setPos(p[5], p[6])
redraw()
})
socket.on('new', function (row) {
console.log('new', row)
for(var i = 0; i < columns.length; i++) {
tables[i].addRow([row[0], row[i+1]])
}
setPos(row[5], row[6])
redraw()
})
}
function drawChart() {
var html = ""
for(var i = 0; i < columns.length; i++) {
html += "<div class=\"chart_div\" id=\"chart_div_"+i+"\"></div>"
}
document.getElementById("charts").innerHTML = html
var charts = []
var tables = []
for(var i = 0; i < columns.length; i++) {
var data = new google.visualization.DataTable()
data.addColumn('number', 'time')
data.addColumn('number', 'hodnota')
tables.push(data)
var chart = new google.visualization.LineChart(document.getElementById('chart_div_'+i))
charts.push(chart)
}
function redraw() {
for(var i = 0; i < columns.length; i++) {
if(chartNo && i === chartNo-1 || !chartNo) {
charts[i].draw(tables[i], {
title: columns[i],
curveType: 'function',
legend: 'none',
})
}
}
}
redraw()
subscribe(tables, debounce(redraw, 100))
}
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDWj0EW71HDDChDXYNyk5GGHqiqV0TppG0&callback=initMap">
</script>
</head>
<body>
<div id="charts"></div>
<div id="map"></div>
</body>
</html>
const express = require('express')
const path = require('path')
const app = express()
const http = require('http').Server(app);
const io = require('socket.io')(http);
const readline = require('readline');
const argv = require('minimist')(process.argv.slice(2))
const live = argv.live
const ioclient = live ? {
emit: () => undefined,
} : require('socket.io-client')('https://live.rajsat.cz/');
app.get('/', (req, res, next) => {
res.sendFile(path.resolve('public/index.html'))
})
let data = []
let sockets = []
app.get('/reset', (req, res, next) => {
data = []
res.send('Reseted data')
})
io.on('connection', function (socket) {
console.log('a user connected')
socket.emit('init', { data })
sockets.push(socket)
socket.on('disconnect', () => {
sockets = sockets.filter(a => a !== socket)
})
socket.on('push', (data) => {
addNewDataPoint(data.value)
})
})
const addNewDataPoint = (value) => {
ioclient.emit('push', {value})
data.push(value)
for(const socket of sockets) {
socket.emit('new', value)
}
console.log(new Date(), 'added', value)
}
http.listen(3003, () => {
console.log('App started on http://0.0.0.0:3003')
})
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
})
function onLine(line) {
if(/!/.exec(line)) return console.log('crc fail', line)
const numbers = line.split('\t').map(a => Number(a))
const [
lat, lon, alt, pres, temp, id, hum, crc,
] = numbers
addNewDataPoint([
id, pres, temp, hum, alt, lat, lon,
])
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
var lingeringLine = "";
process.stdin.on('data', function(chunk) {
lines = chunk.split("\n");
lines[0] = lingeringLine + lines[0];
lingeringLine = lines.pop();
lines.forEach(onLine);
});
process.stdin.on('end', function() {
onLine(lingeringLine);
});
module.exports = {
entry: './src/app.js',
output: {
filename: './public/bundle.js'
}
}
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
accepts@1.3.3, accepts@~1.3.3:
version "1.3.3"
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.3.tgz#c3ca7434938648c3e0d9c1e328dd68b622c284ca"
dependencies:
mime-types "~2.1.11"
negotiator "0.6.1"
after@0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f"
array-flatten@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2"
arraybuffer.slice@0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz#f33b2159f0532a3f3107a272c0ccfbd1ad2979ca"
backo2@1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947"
base64-arraybuffer@0.1.5:
version "0.1.5"
resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8"
base64id@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/base64id/-/base64id-1.0.0.tgz#47688cb99bb6804f0e06d3e763b1c32e57d8e6b6"
better-assert@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522"
dependencies:
callsite "1.0.0"
blob@0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.4.tgz#bcf13052ca54463f30f9fc7e95b9a47630a94921"
callsite@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20"
component-bind@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1"
component-emitter@1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.1.2.tgz#296594f2753daa63996d2af08d15a95116c9aec3"
component-emitter@1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6"
component-inherit@0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/component-inherit/-/component-inherit-0.0.3.tgz#645fc4adf58b72b649d5cae65135619db26ff143"
content-disposition@0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4"
content-type@~1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.2.tgz#b7d113aee7a8dd27bd21133c4dc2529df1721eed"
cookie-signature@1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c"
cookie@0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"
debug@2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da"
dependencies:
ms "0.7.1"
debug@2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.3.3.tgz#40c453e67e6e13c901ddec317af8986cda9eff8c"
dependencies:
ms "0.7.2"
debug@2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.1.tgz#79855090ba2c4e3115cc7d8769491d58f0491351"
dependencies:
ms "0.7.2"
debug@2.6.3:
version "2.6.3"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.3.tgz#0f7eb8c30965ec08c72accfa0130c8b79984141d"
dependencies:
ms "0.7.2"
depd@1.1.0, depd@~1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.0.tgz#e1bd82c6aab6ced965b97b88b17ed3e528ca18c3"
destroy@~1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80"
ee-first@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
encodeurl@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20"
engine.io-client@1.8.3:
version "1.8.3"
resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-1.8.3.tgz#1798ed93451246453d4c6f635d7a201fe940d5ab"
dependencies: