TRACE zobrazeni funkcni
This commit is contained in:
parent
d9f6a56241
commit
42a0dd9681
104
data/index.htm
104
data/index.htm
@ -59,6 +59,47 @@ span.y {
|
|||||||
span.b {
|
span.b {
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Trace elementy */
|
||||||
|
table.trace {
|
||||||
|
font-family: Arial;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.trace tr {
|
||||||
|
line-height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.tr_err {
|
||||||
|
border-left: 5px solid red;
|
||||||
|
padding-left: 5px;
|
||||||
|
background: #ffcccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.tr_inf {
|
||||||
|
border-left: 5px solid green;
|
||||||
|
padding-left: 5px;
|
||||||
|
background: lightgreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.tr_warn {
|
||||||
|
border-left: 5px solid yellow;
|
||||||
|
padding-left: 5px;
|
||||||
|
background: lightyellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.tr_dbg {
|
||||||
|
border-left: 5px solid black;
|
||||||
|
padding-left: 5px;
|
||||||
|
background: lightgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.tr_tm {
|
||||||
|
|
||||||
|
text-align: right;
|
||||||
|
width: 5%;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||||
</head>
|
</head>
|
||||||
@ -69,15 +110,34 @@ span.b {
|
|||||||
function ping() {
|
function ping() {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
if (document.getElementById("live").checked)
|
if (document.getElementById("live").checked)
|
||||||
connection.send('mem');
|
connection.send('status');
|
||||||
else
|
else
|
||||||
connection.send('ping');
|
connection.send('ping');
|
||||||
setTimeout(ping, 5000);
|
setTimeout(ping, 5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTraceTime(stamp) {
|
||||||
|
var hours = Math.trunc((stamp % 86400000) / 3600000); // 86400 equals secs per day
|
||||||
|
var minutes = Math.trunc((stamp % 3600000) / 60000); // 3600 equals secs per minute
|
||||||
|
var seconds = Math.trunc((stamp % 60000) / 1000);
|
||||||
|
var ms = stamp % 1000;
|
||||||
|
var t;
|
||||||
|
|
||||||
|
t = hours.toLocaleString(undefined, {
|
||||||
|
minimumIntegerDigits: 2
|
||||||
|
}) + ':' + minutes.toLocaleString(undefined, {
|
||||||
|
minimumIntegerDigits: 2
|
||||||
|
}) + ':' + seconds.toLocaleString(undefined, {
|
||||||
|
minimumIntegerDigits: 2
|
||||||
|
}) + '.' + ms.toLocaleString(undefined, {
|
||||||
|
minimumIntegerDigits: 3
|
||||||
|
});
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
function connect() {
|
function connect() {
|
||||||
connection = new WebSocket('ws://' + window.location.hostname + ', ["arduino"]');
|
connection = new WebSocket('ws://' + window.location.hostname + '/wss', ['arduino']);
|
||||||
|
|
||||||
connection.onopen = function() {
|
connection.onopen = function() {
|
||||||
console.log('WS Connected');
|
console.log('WS Connected');
|
||||||
@ -94,14 +154,42 @@ span.b {
|
|||||||
connection.onmessage = function(e) {
|
connection.onmessage = function(e) {
|
||||||
var d = JSON.parse(e.data);
|
var d = JSON.parse(e.data);
|
||||||
if (d.type == 'trace') {
|
if (d.type == 'trace') {
|
||||||
document.getElementById('trace').innerHTML = d.text;
|
var h = '<table class="trace" style="width:100%;">';
|
||||||
|
for (var i = 0; i < d.data.length; i++) {
|
||||||
|
h += '<tr><td class="tr_tm">';
|
||||||
|
h += getTraceTime(d.data[i].t);
|
||||||
|
h += '</td><td class="';
|
||||||
|
switch (d.data[i].s) {
|
||||||
|
case 0: // error
|
||||||
|
h += 'tr_err';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: // warning
|
||||||
|
h += 'tr_warn';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: // info
|
||||||
|
h += 'tr_inf';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3: // debug
|
||||||
|
h += 'tr_dbg';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4: // debug more
|
||||||
|
h += 'tr_dbg';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (d.type == 'info') {
|
h += '">' + d.data[i].d;
|
||||||
document.getElementById('reset').innerHTML = d.reset;
|
h += '</td></tr>'
|
||||||
document.getElementById('flash').innerHTML = d.flash;
|
|
||||||
document.getElementById('ram').innerHTML = d.ram;
|
|
||||||
}
|
}
|
||||||
if (d.type == 'mem') {
|
h += '</table>';
|
||||||
|
document.getElementById('trace').innerHTML = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d.type == 'status') {
|
||||||
|
// document.getElementById('reset').innerHTML = d.reset;
|
||||||
|
// document.getElementById('flash').innerHTML = d.flash;
|
||||||
document.getElementById('ram').innerHTML = d.ram;
|
document.getElementById('ram').innerHTML = d.ram;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,9 @@ platform = espressif8266
|
|||||||
board = esp12e
|
board = esp12e
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board_build.flash_mode = dio
|
board_build.flash_mode = dio
|
||||||
upload_port = com25
|
;upload_port = com25
|
||||||
;upload_port = bwrpn5325.local
|
upload_port = finger.local
|
||||||
;upload_port = bwrt00.local
|
;upload_port = /dev/ttyUSB0
|
||||||
; upload_port = 192.168.1.197
|
|
||||||
; upload_port = /dev/ttyUSB0
|
|
||||||
upload_speed = 230400
|
upload_speed = 230400
|
||||||
lib_deps =
|
lib_deps =
|
||||||
http://git.xpablo.cz/pablo2048/Interval.git
|
http://git.xpablo.cz/pablo2048/Interval.git
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#define HTTP_PORT 80 // port, na kterem pobezi HTTP (www) server
|
#define HTTP_PORT 80 // port, na kterem pobezi HTTP (www) server
|
||||||
|
|
||||||
|
#define USE_EDITOR // implementujeme HTML editor
|
||||||
|
|
||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
#define STRINGIFY(x) #x
|
#define STRINGIFY(x) #x
|
||||||
#define TOSTRING(x) STRINGIFY(x)
|
#define TOSTRING(x) STRINGIFY(x)
|
||||||
@ -70,4 +72,7 @@
|
|||||||
|
|
||||||
#define CORS_DEBUG
|
#define CORS_DEBUG
|
||||||
|
|
||||||
|
#define TX_PIN 1
|
||||||
|
#define RX_PIN 3
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
30
src/vsp.ino
30
src/vsp.ino
@ -153,14 +153,13 @@ void setserialport(int32_t speed, int32_t databits, int32_t parity, int32_t stop
|
|||||||
TRACE(TRACE_DEBUG, "Interval set to %i us", (int)work);
|
TRACE(TRACE_DEBUG, "Interval set to %i us", (int)work);
|
||||||
baudtiming = work;
|
baudtiming = work;
|
||||||
// skutecne zmenime nastaveni serioveho portu
|
// skutecne zmenime nastaveni serioveho portu
|
||||||
Serial.flush();
|
SP.flush();
|
||||||
// delay(200);
|
// delay(200);
|
||||||
Serial.end();
|
SP.end();
|
||||||
delay(10); // 100
|
delay(10); // 100
|
||||||
Serial.begin(spd, (SerialConfig)serialMode);
|
SP.begin(spd, (SerialConfig)serialMode);
|
||||||
Serial.setDebugOutput(false);
|
|
||||||
delay(10); // 100
|
delay(10); // 100
|
||||||
Serial.flush();
|
SP.flush();
|
||||||
serial_tx = 0;
|
serial_tx = 0;
|
||||||
serial_rx = 0;
|
serial_rx = 0;
|
||||||
}
|
}
|
||||||
@ -169,9 +168,9 @@ void setserialport(int32_t speed, int32_t databits, int32_t parity, int32_t stop
|
|||||||
void sputchar(uint8_t c)
|
void sputchar(uint8_t c)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fromNet.empty() && Serial.availableForWrite())
|
if (fromNet.empty() && SP.availableForWrite())
|
||||||
{
|
{
|
||||||
Serial.write(c);
|
SP.write(c);
|
||||||
++serial_tx;
|
++serial_tx;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -305,12 +304,11 @@ uint8_t setgetcontrol(uint8_t _ctrl)
|
|||||||
void vsp_init()
|
void vsp_init()
|
||||||
{
|
{
|
||||||
|
|
||||||
Serial.begin(INITIAL_SERIAL_SPEED);
|
SP.begin(INITIAL_SERIAL_SPEED);
|
||||||
#ifdef RX_BUFFER_SIZE
|
#ifdef RX_BUFFER_SIZE
|
||||||
int rxsize = Serial.setRxBufferSize(RX_BUFFER_SIZE);
|
int rxsize = SP.setRxBufferSize(RX_BUFFER_SIZE);
|
||||||
TRACE(TRACE_INFO, F("RX buffser size set to %i"), rxsize);
|
TRACE(TRACE_INFO, F("RX buffser size set to %i"), rxsize);
|
||||||
#endif
|
#endif
|
||||||
Serial.setDebugOutput(false);
|
|
||||||
|
|
||||||
// Inicializace NVT parametru
|
// Inicializace NVT parametru
|
||||||
netterm.init(setserialport, sputchar, nputchar);
|
netterm.init(setserialport, sputchar, nputchar);
|
||||||
@ -320,7 +318,7 @@ void vsp_init()
|
|||||||
|
|
||||||
void vsp_loop()
|
void vsp_loop()
|
||||||
{
|
{
|
||||||
int len;
|
unsigned int len;
|
||||||
|
|
||||||
// kontrola, zda se nepripojil kilent
|
// kontrola, zda se nepripojil kilent
|
||||||
if (server.hasClient())
|
if (server.hasClient())
|
||||||
@ -339,10 +337,10 @@ void vsp_loop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// testovani, zda ma UART nejaka data
|
// testovani, zda ma UART nejaka data
|
||||||
if (int len = Serial.available())
|
if (len = SP.available())
|
||||||
{
|
{
|
||||||
size_t will_copy = (len < sizeof(sbuf)) ? len : sizeof(sbuf);
|
size_t will_copy = (len < sizeof(sbuf)) ? len : sizeof(sbuf);
|
||||||
Serial.readBytes(sbuf, will_copy);
|
SP.readBytes(sbuf, will_copy);
|
||||||
netterm.createsendstream(sbuf, will_copy);
|
netterm.createsendstream(sbuf, will_copy);
|
||||||
serial_rx += will_copy;
|
serial_rx += will_copy;
|
||||||
}
|
}
|
||||||
@ -370,18 +368,18 @@ void vsp_loop()
|
|||||||
|
|
||||||
if (client && client.connected())
|
if (client && client.connected())
|
||||||
{
|
{
|
||||||
uint32_t t = micros();
|
// uint32_t t = micros();
|
||||||
client.write((const uint8_t *)&nvttx[0], read); // data do TCP soketu
|
client.write((const uint8_t *)&nvttx[0], read); // data do TCP soketu
|
||||||
// TRACE(TRACE_INFO, F("TX: %i, took %i us"), read, (int)micros() - t);
|
// TRACE(TRACE_INFO, F("TX: %i, took %i us"), read, (int)micros() - t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// testovani, zda neposlat nejaka data do serioveho rozhrani
|
// testovani, zda neposlat nejaka data do serioveho rozhrani
|
||||||
if (!fromNet.empty() && (len = Serial.availableForWrite()))
|
if (!fromNet.empty() && (len = SP.availableForWrite()))
|
||||||
{
|
{
|
||||||
size_t will_copy = (len < sizeof(sbuf)) ? len : sizeof(sbuf);
|
size_t will_copy = (len < sizeof(sbuf)) ? len : sizeof(sbuf);
|
||||||
will_copy = fromNet.read((char *)sbuf, will_copy);
|
will_copy = fromNet.read((char *)sbuf, will_copy);
|
||||||
Serial.write(sbuf, will_copy);
|
SP.write(sbuf, will_copy);
|
||||||
serial_tx += will_copy;
|
serial_tx += will_copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,9 @@
|
|||||||
#include "FS.h"
|
#include "FS.h"
|
||||||
#endif
|
#endif
|
||||||
#include "obfuscator.h"
|
#include "obfuscator.h"
|
||||||
|
#if (TX_PIN != 1) || (RX_PIN != 3)
|
||||||
|
#include <SoftwareSerial.h>
|
||||||
|
#endif
|
||||||
// Definice obsazeni EEPROM
|
// Definice obsazeni EEPROM
|
||||||
#define elementSize(type, element) sizeof(((type *)0)->element)
|
#define elementSize(type, element) sizeof(((type *)0)->element)
|
||||||
#define countof(a) (sizeof(a) / sizeof(a[0]))
|
#define countof(a) (sizeof(a) / sizeof(a[0]))
|
||||||
@ -90,6 +92,12 @@ uint32_t loopCounter = 0;
|
|||||||
uint32_t loopCounterLast = 0;
|
uint32_t loopCounterLast = 0;
|
||||||
uint32_t loopCounterMax = 1;
|
uint32_t loopCounterMax = 1;
|
||||||
// **** sem je mozne dopsat dalsi globalni promenne
|
// **** sem je mozne dopsat dalsi globalni promenne
|
||||||
|
#if (TX_PIN != 1) || (RX_PIN != 3)
|
||||||
|
SoftwareSerial sport(TX_PIN, RX_PIN);
|
||||||
|
#define SP sport
|
||||||
|
#else
|
||||||
|
#define SP Serial
|
||||||
|
#endif
|
||||||
|
|
||||||
void wificfgcb(wificonfigstate_t state)
|
void wificfgcb(wificonfigstate_t state)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user