![]() |
Forum Index : Microcontroller and PC projects : Suggestions for future version
Author | Message | ||||
toml_12953 Guru ![]() Joined: 13/02/2015 Location: United StatesPosts: 470 |
In some future version, it would be nice to see OPTION INDENT ON/OFF turn indenting on or off in program listings OPTION XON ON/OFF allow XON/XOFF protocol for serial I/O Edited 2025-10-09 08:51 by toml_12953 |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3428 |
XON/XOFF is easily enough implemented. FYI, here's a PC sending 10+ megabytes to a CMM2 at "baud%=1843200" with a 2MB buffer using XON/XOFF flow control: https://www.thebackshed.com/forum/ViewTopic.php?TID=13519&PID=164920#164920#164955 (About 10 posts down from where this link takes you.) For the CMM2: Option explicit Dim string xon=Chr$(17),xoff=Chr$(19),ack=Chr$(6),nak=Chr$(21),a$,b$,c$,d$,fn$ Dim integer i%,j%,k%,l%,m%,n%,cksum%,oldloc%,baud%,nChar% dim float t!,ttx!,tmr! baud%=1843200 ' 115200 230400 460800 1843200 Open "com1:"+Str$(baud)+",2000000" As #1 fn$="tst.txt" print "Trying to get "+fn$ open "\"+fn$ for output as #2 print #1,fn$+xon; oldloc%=0 cksum%=0 nChar%=0 timer=0 do while loc(#1) = 0 and timer < 10000: loop if loc(#1) = 0 then print "File Not Received: "+fn+"--exiting" print #1,chr$(27); ' EOT pause 1000 end endif timer=0 t!=0 ttx!=0 tmr!=timer do l%=loc(#1) if l%=0 then ' transmission done if cksum%>0 then ' something received print #1,str$(nChar%)+","+str$(cksum%)+xoff print " Bytes, checksum: "+str$(nChar%)+","+str$(cksum%)+xoff exit do else pause 2000 ' allow more time for start-up if loc(#1) = 0 then ' nothing received print "File Not Received--exiting" ' exit do print #1,xon; endif endif elseif l%>1000000 or oldloc%=l% then ' this block is done; xoff and write to SD card print #1,xoff; ttx!=ttx!+(timer-tmr!): print "*"; do while loc(#1) > 0 ' clear all characters from buffer b$=input$(255,#1) j%=Len(b$) For i%=1 To j% c$=Mid$(b$,i%,1) cksum%=cksum%+Asc(c$) nChar%=nChar%+1 Next i% print #2,b$; loop print #1,xon; tmr!=timer endif oldloc%=l% pause 1000 ' wait a second loop t!=timer print #1,chr$(27); ' EOT on error skip 1 close #1 on error skip 1 close #2 print nChar%;" Characters; ";t!/1000;" seconds; ";ttx!/1000;" seconds transmitting; checksum: ";cksum% print int(nChar%/(t!/1000));" bytes per second total; ";int(nChar%/(ttx!/1000));" bytes per second (to transmit)" (The CMM2 is sending XOFF when the end of its buffer is approaching.) PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
toml_12953 Guru ![]() Joined: 13/02/2015 Location: United StatesPosts: 470 |
I was really looking for it to be used by the console. I have a serial printer hooked up and would like XON/XOFF implemented when I redirect the console to the serial port so the printer won't lose characters. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |