« first day (26 days earlier)      last day (21 days later) » 

8:41 AM
No problem. I will be updating you with my progress reports from time to time. This afternoon I have tided up the LewanSoul 3V3 to 5V0 up level shifter and full duplex to half duplex converter and tested my old working program of reading Vin for the last time, before testing the new FeeTech SCS servo STS3215.
This is the photo of final setup based on TXS0104. The 3V3 to 5V0 still has a problem of logic Low at 3V3 side is still too high of around 1V, instead of the much lower 0.5V or even lower. However reading characters is more or less OK, except intermittent reading errors of the reply packet from servo.
This is a full listing of the python program, with sample output.
This is the full listing with sample output. The reply/status packet has a superfous "h" after the byte "x1b" - b'UU\x01\x03\x1b\xe0UU\x01\x05\x1bh\x13c'
# srv_util_01_v171.py
# LX-824HV Testing v2.0  tlfong01 2020sep30hkt1618

# HiWonder serial bus servo LX-824HV LewanSoul command testing (2020sep24)
# Rpi4B buster (r2020feb13), python 3.7.3 (r2019dec20), thonny v3.2.7 (r2020jan22)

from   time import sleep
import serial

serialPort0 = serial.Serial(port = '/dev/serial0',
        baudrate = 9600,
        parity = serial.PARITY_NONE,
        stopbits = serial.STOPBITS_ONE,
        bytesize = serial.EIGHTBITS,
        timeout= 1)

def setSerialPortBaudRate(serialPort, baudrate):
Jogging time. See you later this evening or tomorrow. Cheers.
 
9:12 AM
Just now I used CuteCom to test ReadVin command and found it OK, without the intermittent reading error. Now everything is ready to use the TTLink Mini to test the FeeTech STS 3218 servo.
 
 
5 hours later…
2:16 PM
Progress Report 2020sep30: (1) My toy TTLink Mini came to town this afternoon. Will collect tomorrow. (2) Have skimmed SCServo Library (the .h and .cpp file) and made the following wild guess. (3) To read Vin of Servo #1, I need to send 6 bytes to the servo. The 6 bytes are: (a) header 0xff, 0xff, (b) servoId, (c) memory address = Present Voltage ?, (d) message length ?, (e) 1?, (f) function name INST_READ.
One thing I don't know is how to send the checksum. It seems that I need to use a virtual function writeSCS(), which is one of the following 4 virtual functions: (i) virtual int writeSCS(unsigned char *nDat, int nLen) = 0;
(ii) virtual int readSCS(unsigned char *nDat, int nLen) = 0;
(iii) virtual int writeSCS(unsigned char bDat) = 0;
(iv) virtual void flushSCS() = 0;
I forgot what is a virtual function. So I searched StackOverflow and found the following hugely popular SO Q&A: ***Why do we need virtual functions in C++?*** - StackOverflow, Asked 10 years ago, Viewed 566k times, 1360 upvotes
https://stackoverflow.com/questions/2391679/why-do-we-need-virtual-functions-in-c
Now I think I need to spend "some time" to read this "virtual function" Q&A.
 
2:41 PM
I found the above hugely popular question on virtual function has 26 answers. I quickly read the first answer which has 2000+ upvotes. I think I vaguely understand the answer (Yes, I did spend long hours self studying OOP, including class inheritance, though I always try to avoid using OOP.)
I once tried to play with class inheritance with my Arduino, but I found the Arduino RAM is ridiculously small to do meaningful OOP, compared to Rpi, So I switched to Rpi and left Arduino for good. I confess I am a pure FP guy. :)
Ah, bed time. See you tomorrow.
 

« first day (26 days earlier)      last day (21 days later) »