diff --git a/F1:F103/BISS_C_encoders/Makefile b/F1:F103/BISS_C_encoders/Makefile index 3aa2506..8496007 100644 --- a/F1:F103/BISS_C_encoders/Makefile +++ b/F1:F103/BISS_C_encoders/Makefile @@ -6,4 +6,4 @@ LDSCRIPT ?= stm32f103xB.ld DEFINES := -DSTM32F10X_MD include ../makefile.f1 -include ../../makefile.stm32 +include ../makefile.stm32 diff --git a/F1:F103/BISS_C_encoders/encoders.bin b/F1:F103/BISS_C_encoders/encoders.bin index dcf8cfb..758d54c 100755 Binary files a/F1:F103/BISS_C_encoders/encoders.bin and b/F1:F103/BISS_C_encoders/encoders.bin differ diff --git a/F1:F103/BISS_C_encoders/encoders.creator.user b/F1:F103/BISS_C_encoders/encoders.creator.user index efd9972..3ddf322 100644 --- a/F1:F103/BISS_C_encoders/encoders.creator.user +++ b/F1:F103/BISS_C_encoders/encoders.creator.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -86,6 +86,7 @@ true + 0 @@ -163,6 +164,7 @@ ProjectExplorer.CustomExecutableRunConfiguration false + true true @@ -197,6 +199,7 @@ ProjectExplorer.CustomExecutableRunConfiguration false + true true @@ -207,10 +210,6 @@ ProjectExplorer.Project.TargetCount 1 - - ProjectExplorer.Project.Updater.FileVersion - 22 - Version 22 diff --git a/F1:F103/BISS_C_encoders/proto.c b/F1:F103/BISS_C_encoders/proto.c index 4fea9ce..b096ddb 100644 --- a/F1:F103/BISS_C_encoders/proto.c +++ b/F1:F103/BISS_C_encoders/proto.c @@ -496,7 +496,7 @@ static errcode_e help(_U_ cmd_e idx, _U_ char* par){ void parse_cmd(char *cmd){ errcode_e ecode = ERR_BADCMD; // command and its parameter -CMDWRn(cmd); +//CMDWRn(cmd); char *cmdstart = omit_spaces(cmd), *parstart = NULL; if(!cmdstart) goto retn; char *ptr = cmdstart; diff --git a/F1:F103/BISS_C_encoders/ringbuffer.c b/F1:F103/BISS_C_encoders/ringbuffer.c index b0ffe8e..d444ec6 100644 --- a/F1:F103/BISS_C_encoders/ringbuffer.c +++ b/F1:F103/BISS_C_encoders/ringbuffer.c @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +#include // memcpy #include "ringbuffer.h" static int datalen(ringbuffer *b){ @@ -57,11 +58,11 @@ int RB_hasbyte(ringbuffer *b, uint8_t byte){ b->busy = 0; return ret; } - +/* // poor memcpy static void mcpy(uint8_t *targ, const uint8_t *src, int l){ while(l--) *targ++ = *src++; -} +}*/ // increment head or tail TRUE_INLINE void incr(ringbuffer *b, volatile int *what, int n){ @@ -76,9 +77,11 @@ static int read(ringbuffer *b, uint8_t *s, int len){ int _1st = b->length - b->head; if(_1st > l) _1st = l; if(_1st > len) _1st = len; - mcpy(s, b->data + b->head, _1st); + //mcpy(s, b->data + b->head, _1st); + memcpy(s, b->data + b->head, _1st); if(_1st < len && l > _1st){ - mcpy(s+_1st, b->data, l - _1st); + //mcpy(s+_1st, b->data, l - _1st); + memcpy(s+_1st, b->data, l - _1st); incr(b, &b->head, l); return l; } @@ -132,9 +135,11 @@ static int write(ringbuffer *b, const uint8_t *str, int l){ if(l > r || !l) return 0; int _1st = b->length - b->tail; if(_1st > l) _1st = l; - mcpy(b->data + b->tail, str, _1st); + //mcpy(b->data + b->tail, str, _1st); + memcpy(b->data + b->tail, str, _1st); if(_1st < l){ // add another piece from start - mcpy(b->data, str+_1st, l-_1st); + //mcpy(b->data, str+_1st, l-_1st); + memcpy(b->data, str+_1st, l-_1st); } incr(b, &b->tail, l); return l; diff --git a/F1:F103/BISS_C_encoders/usb_dev.c b/F1:F103/BISS_C_encoders/usb_dev.c index fd596e2..feee2f4 100644 --- a/F1:F103/BISS_C_encoders/usb_dev.c +++ b/F1:F103/BISS_C_encoders/usb_dev.c @@ -254,7 +254,12 @@ int USB_sendall(uint8_t ifno){ int USB_send(uint8_t ifno, const uint8_t *buf, int len){ if(!buf || !CDCready[ifno] || !len) return FALSE; DBG("USB_send"); + uint32_t T0 = Tms; while(len){ + if(Tms - T0 > DISCONN_TMOUT){ + break_handler(ifno); + return FALSE; + } if(!CDCready[ifno]) return FALSE; IWDG->KR = IWDG_REFRESH; int a = RB_write((ringbuffer*)&rbout[ifno], buf, len); @@ -272,7 +277,12 @@ int USB_send(uint8_t ifno, const uint8_t *buf, int len){ int USB_putbyte(uint8_t ifno, uint8_t byte){ if(!CDCready[ifno]) return FALSE; int l = 0; + uint32_t T0 = Tms; while((l = RB_write((ringbuffer*)&rbout[ifno], &byte, 1)) != 1){ + if(Tms - T0 > DISCONN_TMOUT){ + break_handler(ifno); + return FALSE; + } if(!CDCready[ifno]) return FALSE; IWDG->KR = IWDG_REFRESH; if(l == 0){ // overfull @@ -299,7 +309,7 @@ int USB_sendstr(uint8_t ifno, const char *string){ * @return amount of received bytes (negative, if overfull happened) */ int USB_receive(uint8_t ifno, uint8_t *buf, int len){ - chkin(ifno); + chkin(ifno); // rxtx_handler could leave last message unwritten if buffer was busy if(bufovrfl[ifno]){ DBG("Buffer overflow"); DBGs(uhex2str(ifno)); @@ -320,7 +330,7 @@ int USB_receive(uint8_t ifno, uint8_t *buf, int len){ * @return strlen or negative value indicating overflow (if so, string won't be ends with 0 and buffer should be cleared) */ int USB_receivestr(uint8_t ifno, char *buf, int len){ - chkin(ifno); + chkin(ifno); // rxtx_handler could leave last message unwritten if buffer was busy if(bufovrfl[ifno]){ while(1 != RB_clearbuf((ringbuffer*)&rbin[ifno])); bufovrfl[ifno] = 0; diff --git a/F1:F103/BISS_C_encoders/version.inc b/F1:F103/BISS_C_encoders/version.inc index d66eb33..00fd981 100644 --- a/F1:F103/BISS_C_encoders/version.inc +++ b/F1:F103/BISS_C_encoders/version.inc @@ -1,2 +1,2 @@ -#define BUILD_NUMBER "126" -#define BUILD_DATE "2025-08-24" +#define BUILD_NUMBER "130" +#define BUILD_DATE "2026-02-09"