mirror of https://github.com/arendst/Tasmota.git
Merge pull request #7743 from Staars/development
GPS-driver: virtual port improvement, set lat/lon in settings (bugfix)
This commit is contained in:
commit
d76d6474cd
|
@ -23,6 +23,8 @@
|
||||||
Version Date Action Description
|
Version Date Action Description
|
||||||
--------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
0.9.3.0 20200214 integrate - fix set lat/lon via commandd 13, V-Port now works parallel
|
||||||
|
---
|
||||||
0.9.2.0 20200110 integrate - Added UART-over-TCP/IP-bridge (virtual serial port). Minor tweaks.
|
0.9.2.0 20200110 integrate - Added UART-over-TCP/IP-bridge (virtual serial port). Minor tweaks.
|
||||||
---
|
---
|
||||||
0.9.1.0 20191216 integrate - Added pin specifications from Tasmota WEB UI. Minor tweaks.
|
0.9.1.0 20191216 integrate - Added pin specifications from Tasmota WEB UI. Minor tweaks.
|
||||||
|
@ -244,8 +246,6 @@ struct UBX_t {
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint32_t last_iTOW;
|
uint32_t last_iTOW;
|
||||||
int32_t last_lat;
|
|
||||||
int32_t last_lon;
|
|
||||||
int32_t last_alt;
|
int32_t last_alt;
|
||||||
uint32_t last_hAcc;
|
uint32_t last_hAcc;
|
||||||
uint32_t last_vAcc;
|
uint32_t last_vAcc;
|
||||||
|
@ -273,6 +273,8 @@ struct UBX_t {
|
||||||
CFG_RATE cfgRate;
|
CFG_RATE cfgRate;
|
||||||
} Message;
|
} Message;
|
||||||
|
|
||||||
|
uint8_t TCPbuf[UBX_SERIAL_BUFFER_SIZE];
|
||||||
|
size_t TCPbufSize;
|
||||||
} UBX;
|
} UBX;
|
||||||
|
|
||||||
enum UBXMsgType {
|
enum UBXMsgType {
|
||||||
|
@ -377,6 +379,10 @@ uint32_t UBXprocessGPS()
|
||||||
while ( UBXSerial->available() ) {
|
while ( UBXSerial->available() ) {
|
||||||
data_bytes++;
|
data_bytes++;
|
||||||
byte c = UBXSerial->read();
|
byte c = UBXSerial->read();
|
||||||
|
if (UBX.mode.runningVPort){
|
||||||
|
UBX.TCPbuf[data_bytes-1] = c; // immediately copy byte to TCP-buf
|
||||||
|
UBX.TCPbufSize = data_bytes;
|
||||||
|
}
|
||||||
if ( fpos < 2 ) {
|
if ( fpos < 2 ) {
|
||||||
// For the first two bytes we are simply looking for a match with the UBX header bytes (0xB5,0x62)
|
// For the first two bytes we are simply looking for a match with the UBX header bytes (0xB5,0x62)
|
||||||
if ( c == UBX.UBX_HEADER[fpos] ) {
|
if ( c == UBX.UBX_HEADER[fpos] ) {
|
||||||
|
@ -585,8 +591,8 @@ void UBXSelectMode(uint16_t mode)
|
||||||
UBX.mode.forceUTCupdate = false;
|
UBX.mode.forceUTCupdate = false;
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
Settings.latitude = UBX.state.last_lat;
|
Settings.latitude = UBX.rec_buffer.values.lat/10;
|
||||||
Settings.longitude = UBX.state.last_lon;
|
Settings.longitude = UBX.rec_buffer.values.lon/10;
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
vPortServer.begin();
|
vPortServer.begin();
|
||||||
|
@ -680,49 +686,24 @@ void UBXHandleOther(void)
|
||||||
|
|
||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
|
|
||||||
void UBXhandleVPort(){
|
void UBXLoop50msec(void)
|
||||||
static uint32_t idx = 0;
|
{
|
||||||
static uint8_t buf[UBX_SERIAL_BUFFER_SIZE];
|
// handle virtual serial port
|
||||||
// static uint32_t tBufMax = 0;
|
if (UBX.mode.runningVPort){
|
||||||
// static uint32_t sBufMax = 0;
|
|
||||||
|
|
||||||
if(!vPortClient.connected()) {
|
if(!vPortClient.connected()) {
|
||||||
vPortClient = vPortServer.available();
|
vPortClient = vPortServer.available();
|
||||||
}
|
}
|
||||||
|
|
||||||
while(vPortClient.available()) {
|
while(vPortClient.available()) {
|
||||||
buf[idx] = (uint8_t)vPortClient.read();
|
byte _newByte = vPortClient.read();
|
||||||
if(idx<sizeof(buf)-1) idx++;
|
UBXSerial->write(_newByte);
|
||||||
}
|
|
||||||
if(idx!=0) {
|
|
||||||
UBXSerial->write(buf, idx);
|
|
||||||
// if(idx>tBufMax) {
|
|
||||||
// tBufMax = idx;
|
|
||||||
// AddLog_P2(LOG_LEVEL_INFO, PSTR("VPORT: new max. tcp buffer size: %u"),tBufMax);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
idx = 0;
|
|
||||||
|
|
||||||
while(UBXSerial->available()) {
|
|
||||||
buf[idx] = (char)UBXSerial->read();
|
|
||||||
if(idx<sizeof(buf)-1) idx++;
|
|
||||||
}
|
|
||||||
if(idx!=0) {
|
|
||||||
vPortClient.write((char*)buf, idx);
|
|
||||||
// if(idx>sBufMax) {
|
|
||||||
// sBufMax = idx;
|
|
||||||
// AddLog_P2(LOG_LEVEL_INFO, PSTR("VPORT: new max. serial buffer size: %u"),sBufMax);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
idx = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UBXTimeServer()
|
if (UBX.TCPbufSize!=0){
|
||||||
{
|
vPortClient.write((char*)UBX.TCPbuf, UBX.TCPbufSize);
|
||||||
if(UBX.mode.runningVPort){
|
UBX.TCPbufSize = 0;
|
||||||
UBXhandleVPort();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// handle NTP-server
|
||||||
if(UBX.mode.runningNTP){
|
if(UBX.mode.runningNTP){
|
||||||
timeServer.processOneRequest(Rtc.utc_time, UBX.state.last_iTOW%1000);
|
timeServer.processOneRequest(Rtc.utc_time, UBX.state.last_iTOW%1000);
|
||||||
}
|
}
|
||||||
|
@ -733,10 +714,6 @@ void UBXLoop(void)
|
||||||
static uint16_t counter; //count up every 100 msec
|
static uint16_t counter; //count up every 100 msec
|
||||||
static bool new_position;
|
static bool new_position;
|
||||||
|
|
||||||
if(UBX.mode.runningVPort) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t msgType = UBXprocessGPS();
|
uint32_t msgType = UBXprocessGPS();
|
||||||
|
|
||||||
switch(msgType){
|
switch(msgType){
|
||||||
|
@ -899,7 +876,7 @@ bool Xsns60(uint8_t function)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FUNC_EVERY_50_MSECOND:
|
case FUNC_EVERY_50_MSECOND:
|
||||||
UBXTimeServer(); // handles virtual serial port too
|
UBXLoop50msec(); // handles virtual serial port and NTP server
|
||||||
break;
|
break;
|
||||||
case FUNC_EVERY_100_MSECOND:
|
case FUNC_EVERY_100_MSECOND:
|
||||||
#ifdef USE_FLOG
|
#ifdef USE_FLOG
|
||||||
|
|
Loading…
Reference in New Issue