diff --git a/data/index.htm b/data/index.htm
index 62fee6c..f991e1c 100644
--- a/data/index.htm
+++ b/data/index.htm
@@ -59,6 +59,47 @@ span.y {
span.b {
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%;
+}
+
@@ -69,15 +110,34 @@ span.b {
function ping() {
if (connected) {
if (document.getElementById("live").checked)
- connection.send('mem');
+ connection.send('status');
else
connection.send('ping');
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() {
- connection = new WebSocket('ws://' + window.location.hostname + ', ["arduino"]');
+ connection = new WebSocket('ws://' + window.location.hostname + '/wss', ['arduino']);
connection.onopen = function() {
console.log('WS Connected');
@@ -94,14 +154,42 @@ span.b {
connection.onmessage = function(e) {
var d = JSON.parse(e.data);
if (d.type == 'trace') {
- document.getElementById('trace').innerHTML = d.text;
+ var h = '
';
+ for (var i = 0; i < d.data.length; i++) {
+ h += '';
+ h += getTraceTime(d.data[i].t);
+ h += ' | ' + d.data[i].d;
+ h += ' |
'
+ }
+ h += '
';
+ document.getElementById('trace').innerHTML = h;
}
- if (d.type == 'info') {
- document.getElementById('reset').innerHTML = d.reset;
- document.getElementById('flash').innerHTML = d.flash;
- document.getElementById('ram').innerHTML = d.ram;
- }
- if (d.type == 'mem') {
+
+ if (d.type == 'status') {
+ // document.getElementById('reset').innerHTML = d.reset;
+ // document.getElementById('flash').innerHTML = d.flash;
document.getElementById('ram').innerHTML = d.ram;
}
}
diff --git a/platformio.ini b/platformio.ini
index 51cea04..c9539bd 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -6,11 +6,9 @@ platform = espressif8266
board = esp12e
framework = arduino
board_build.flash_mode = dio
-upload_port = com25
-;upload_port = bwrpn5325.local
-;upload_port = bwrt00.local
-; upload_port = 192.168.1.197
-; upload_port = /dev/ttyUSB0
+;upload_port = com25
+upload_port = finger.local
+;upload_port = /dev/ttyUSB0
upload_speed = 230400
lib_deps =
http://git.xpablo.cz/pablo2048/Interval.git
diff --git a/src/configuration.h b/src/configuration.h
index a748b7f..1878be4 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -21,6 +21,8 @@
#define HTTP_PORT 80 // port, na kterem pobezi HTTP (www) server
+#define USE_EDITOR // implementujeme HTML editor
+
#ifdef DEBUG_BUILD
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
@@ -70,4 +72,7 @@
#define CORS_DEBUG
+#define TX_PIN 1
+#define RX_PIN 3
+
#endif
diff --git a/src/vsp.ino b/src/vsp.ino
index 759c901..0992a05 100644
--- a/src/vsp.ino
+++ b/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);
baudtiming = work;
// skutecne zmenime nastaveni serioveho portu
- Serial.flush();
+ SP.flush();
// delay(200);
- Serial.end();
+ SP.end();
delay(10); // 100
- Serial.begin(spd, (SerialConfig)serialMode);
- Serial.setDebugOutput(false);
+ SP.begin(spd, (SerialConfig)serialMode);
delay(10); // 100
- Serial.flush();
+ SP.flush();
serial_tx = 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)
{
- if (fromNet.empty() && Serial.availableForWrite())
+ if (fromNet.empty() && SP.availableForWrite())
{
- Serial.write(c);
+ SP.write(c);
++serial_tx;
}
else
@@ -305,12 +304,11 @@ uint8_t setgetcontrol(uint8_t _ctrl)
void vsp_init()
{
- Serial.begin(INITIAL_SERIAL_SPEED);
+ SP.begin(INITIAL_SERIAL_SPEED);
#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);
#endif
- Serial.setDebugOutput(false);
// Inicializace NVT parametru
netterm.init(setserialport, sputchar, nputchar);
@@ -320,7 +318,7 @@ void vsp_init()
void vsp_loop()
{
- int len;
+ unsigned int len;
// kontrola, zda se nepripojil kilent
if (server.hasClient())
@@ -339,10 +337,10 @@ void vsp_loop()
}
// 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);
- Serial.readBytes(sbuf, will_copy);
+ SP.readBytes(sbuf, will_copy);
netterm.createsendstream(sbuf, will_copy);
serial_rx += will_copy;
}
@@ -370,18 +368,18 @@ void vsp_loop()
if (client && client.connected())
{
- uint32_t t = micros();
+// uint32_t t = micros();
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);
}
}
// 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);
will_copy = fromNet.read((char *)sbuf, will_copy);
- Serial.write(sbuf, will_copy);
+ SP.write(sbuf, will_copy);
serial_tx += will_copy;
}
diff --git a/src/xpvsp.ino b/src/xpvsp.ino
index 4272d1d..6365a06 100644
--- a/src/xpvsp.ino
+++ b/src/xpvsp.ino
@@ -49,7 +49,9 @@
#include "FS.h"
#endif
#include "obfuscator.h"
-
+#if (TX_PIN != 1) || (RX_PIN != 3)
+ #include
+#endif
// Definice obsazeni EEPROM
#define elementSize(type, element) sizeof(((type *)0)->element)
#define countof(a) (sizeof(a) / sizeof(a[0]))
@@ -90,6 +92,12 @@ uint32_t loopCounter = 0;
uint32_t loopCounterLast = 0;
uint32_t loopCounterMax = 1;
// **** 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)
{