gets nothing for me but framing and parity errors?
To be more helpful, first some TL;DR:
I'd like to reuse - and showcase the device - but being it in the context and connectivity of more recent peripherals.
For exploration and possibly future interfacing, I picked Espruino Pico, because I have access to the device's TTL signal levels before it's fed into RS-232 drivers that do the typical -12V/+12V business or into FSK (Frequncy Shift Keying) communication over regular copper phone lines as of that time for remote operation. Commisurate with the means at that time is the speed: about 300 baud or 300 bps (bits per second) - Baud from French Baudot 5-bit code, invented 150+ years ago for telegraphy...
Espruino and Pico are a good match, for easy coding and quick to apply, and has TTL / 5V signal compatibility. Espruino software supports Serial communication with configuration option for number of data, parity and stop bits.
Unfortunately, for yet unknown reason, the code below
Serial1.setup(300, {rx:B7, tx:B6, parity:"o", errors:true});
Serial1.on('data', function (data) { print(data); });
if (errs) {
Serial1.on('parity', ()=>console.log('P'));
Serial1.on('framing', ()=>console.log('F'));
}
prints nothing but Fs for framing and Ps for parity errors for a block of 0x200xAA and another block of 0x200x55. Looking a the signal timings, it shows that a bit is around 0.003148 seconds, yielding a rate of 318 bps. 18 is about a 6% error, over the 10-1/2 sampling times this makes worst case 63% 'off-beat'. Center sampling can at best handle a 40%..45% off-beat situation, so no surprise it failed... But I'm in for a greater surprise: even with setup adjusted to 318 bps, the result is equally depressing: PF.
Since the 40+ year old device is so slow, I just used Pico and a few lines of code to find the timings including baud rate AND visualization of the signal shape... The code looks like this:
var baudFindWId = null // baud find watch ID
, ths, lst // this and last bit's Espruino getTime()
, SOD = B7 // USART1 B7 rx - watching device's Serial Out Data
;
function findBaud() {
unfindBaud();
pinMode(SOD,"input");
lst = getTime();
baudFindWId = setWatch( function(s) {
console.log(
( (s.state)
? "|_" // low signal for...
: "_|" ) // high signal for...
, (ths=getTime())-lst // ...t sec(s) before switching to high, rsp low
);
lst=ths;
}, SOD, {repeat:true, edge:"both", bounce:10} );
log("made SOD watched");
}
function unfindBaud() {
if (baudFindWId) {
baudFindWId = clearWatch(baudFindWId);
log("made baud unfound");
} else {
log("baud is (already) unfound");
}
}
The device was setup to transmit this sequence of 0x20 0x##s bytes (ignore var t=... js, it overcome render challenges of fixed font text blocks in forum... how to <pre> w/ line # but w/o coloring?):
var t=`
_| 9.82303428649 // <--- A) idle, since setup / before tx and
|_ 0.02833652496 before start of 1st byte 0x00
_| 0.00949668884 // <--- B) before start of 2nd byte 0x01
|_ 0.00314712524
_| 0.00315475463
|_ 0.02518844604
_| 0.00633430480 // <--- C) before start of 3rd byte 0x20
|_ 0.00630855560
_| 0.00314426422
|_ 0.02202987670
_| 0.00633335113 // <--- D) before start of 4th byte 0x40
|_ 0.00944900512
_| 0.00314807891
|_ 0.01888561248
_| 0.00635814666 // <--- E) before start of 5th byte 0x80
|_ 0.01259136199
_| 0.00315093994
|_ 0.01572895050
_| 0.00633239746 // <--- F) before start of 6th byte 0x10
....
....
_| 0.00948810577
|_ 0.02837276458
// <--- G) unknown idle time after transmission
`;
Since in above 'graph' the signal level line show NOT to time, I manually extended them according the times measured. I commented start bit, data bits 0 thru 7, odd parity bit, stop bit and the idle or byte separation 'bit'. With the extension, the signal lines make it very obvious what is going on:
Bitbanging shows that the device produces what it states... with the minor adjustment of the baud rate (which btw does not really matter, since the partner device is of the same make in hard and software (but I consider changing the device's code to be as close as possible to the 300 - or configurable - bps... after all, it does bit banging too, but no unpredictability by garbage collect or interrupts...). Bitbanging will also get me reading the device, but 40+ and the 32 Bit ST ... what ever should have outgrown that need... after all.
The device in today's money is about $1120... $290 then... Espruino Pico today cost about $25. Considering these numbers just from a point of money, would it be fair to conclude: You get what you pay for ? - The answer to that is an easy: no.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
To cut to the chase:
Question: What do I do wrong that Espruino Pico's
gets nothing for me but framing and parity errors?
To be more helpful, first some TL;DR:
I'd like to reuse - and showcase the device - but being it in the context and connectivity of more recent peripherals.
For exploration and possibly future interfacing, I picked Espruino Pico, because I have access to the device's TTL signal levels before it's fed into RS-232 drivers that do the typical -12V/+12V business or into FSK (Frequncy Shift Keying) communication over regular copper phone lines as of that time for remote operation. Commisurate with the means at that time is the speed: about 300 baud or 300 bps (bits per second) - Baud from French Baudot 5-bit code, invented 150+ years ago for telegraphy...
Espruino and Pico are a good match, for easy coding and quick to apply, and has TTL / 5V signal compatibility. Espruino software supports Serial communication with configuration option for number of data, parity and stop bits.
Unfortunately, for yet unknown reason, the code below
prints nothing but
F
s for framing andP
s for parity errors for a block of0x20
0xAA
and another block of0x20
0x55
. Looking a the signal timings, it shows that a bit is around0.003148
seconds, yielding a rate of 318 bps. 18 is about a 6% error, over the 10-1/2 sampling times this makes worst case 63% 'off-beat'. Center sampling can at best handle a 40%..45% off-beat situation, so no surprise it failed... But I'm in for a greater surprise: even with setup adjusted to 318 bps, the result is equally depressing:PF
.Since the 40+ year old device is so slow, I just used Pico and a few lines of code to find the timings including baud rate AND visualization of the signal shape... The code looks like this:
The device was setup to transmit this sequence of 0x20 0x##s bytes (ignore
var t=...
js, it overcome render challenges of fixed font text blocks in forum... how to <pre> w/ line # but w/o coloring?):The generated out put in console looks like this:
Since in above 'graph' the signal level line show NOT to time, I manually extended them according the times measured. I commented start bit, data bits 0 thru 7, odd parity bit, stop bit and the idle or byte separation 'bit'. With the extension, the signal lines make it very obvious what is going on:
End of
TL;DR
and back to the question:What is wrong with my setup of
Serial1
?Bitbanging shows that the device produces what it states... with the minor adjustment of the baud rate (which btw does not really matter, since the partner device is of the same make in hard and software (but I consider changing the device's code to be as close as possible to the 300 - or configurable - bps... after all, it does bit banging too, but no unpredictability by garbage collect or interrupts...). Bitbanging will also get me reading the device, but 40+ and the 32 Bit ST ... what ever should have outgrown that need... after all.
The device in today's money is about $1120... $290 then... Espruino Pico today cost about $25. Considering these numbers just from a point of money, would it be fair to conclude: You get what you pay for ? - The answer to that is an easy: no.
What do I do wrong in my Serial1 setup and use?