@@ -52,10 +52,10 @@ <h2 id="getting-started">Getting started</h2>
5252</ iframe >
5353</ div >
5454< p > Please note, that at the first start of the Android version of
55- SmallBASIC, the editor is turned off. A mouse click on a program name
56- will start it immediately. If you want to edit the file, please turn on
57- the editor by clicking on the three dots in the lower right corner and
58- choosing the entry < code > Editor [OFF]</ code > to enable the editor.</ p >
55+ SmallBASIC, the editor is turned off. A tap on a program name will start
56+ it immediately. If you want to edit the file, please turn on the editor
57+ by tapping on the three dots in the lower right corner and choosing the
58+ entry < code > Editor [OFF]</ code > to enable the editor.</ p >
5959< h2 id ="step-by-step-guide "> Step-by-Step Guide</ h2 >
6060< p > < img src ="/images/android_menu1.png "
6161title ="System Menu button " /> </ p >
@@ -235,6 +235,59 @@ <h2 id="https-web-request">HTTPS Web request</h2>
235235< p > The code snippet demonstrates how to use REQUEST to interact with a
236236specified endpoint, providing necessary data and token for
237237authentication.</ p >
238+ < h2 id ="iot-device-communication "> IoT Device Communication</ h2 >
239+ < h3 id ="usb-serial-support "> USB Serial Support</ h3 >
240+ < p > These functions allow you to connect, send, and receive data over a
241+ USB serial connection.</ p >
242+ < p > 🔌 Open a USB Serial Connection</ p >
243+ < div class ="sourceCode " id ="cb15 "> < pre
244+ class ="sourceCode smallbasic "> < code class ="sourceCode smallbasic "> < span id ="cb15-1 "> < a href ="#cb15-1 " aria-hidden ="true " tabindex ="-1 "> </ a > < span class ="dt "> const</ span > usb = android.openUsbSerial(vendorId, [baud], [timeout])</ span > </ code > </ pre > </ div >
245+ < p > Parameters:</ p >
246+ < ul >
247+ < li > < code > vendorId</ code > : (required) The USB device’s Vendor ID.</ li >
248+ < li > < code > baud</ code > : (optional) The baud rate for communication
249+ (default: 19200).</ li >
250+ < li > < code > timeout</ code > : (optional) imeout in milliseconds for receive
251+ operations (default: 5000 ms).</ li >
252+ </ ul >
253+ < p > Returns:</ p >
254+ < ul >
255+ < li > A USB serial object to be used with other USB functions.</ li >
256+ </ ul >
257+ < p > ❌ Close the USB Connection</ p >
258+ < div class ="sourceCode " id ="cb16 "> < pre
259+ class ="sourceCode smallbasic "> < code class ="sourceCode smallbasic "> < span id ="cb16-1 "> < a href ="#cb16-1 " aria-hidden ="true " tabindex ="-1 "> </ a > usb.< span class ="fu "> close</ span > ()</ span > </ code > </ pre > </ div >
260+ < p > Closes the current USB connection. Always call this when you’re done
261+ using the device.</ p >
262+ < p > 📋 Get Device Description</ p >
263+ < div class ="sourceCode " id ="cb17 "> < pre
264+ class ="sourceCode smallbasic "> < code class ="sourceCode smallbasic "> < span id ="cb17-1 "> < a href ="#cb17-1 " aria-hidden ="true " tabindex ="-1 "> </ a > usb.description()</ span > </ code > </ pre > </ div >
265+ < p > Returns a string with details about the connected USB device, such as
266+ product name or manufacturer info (if available).</ p >
267+ < p > 📥 Receive Data</ p >
268+ < div class ="sourceCode " id ="cb18 "> < pre
269+ class ="sourceCode smallbasic "> < code class ="sourceCode smallbasic "> < span id ="cb18-1 "> < a href ="#cb18-1 " aria-hidden ="true " tabindex ="-1 "> </ a > dat = usb.receive()</ span > </ code > </ pre > </ div >
270+ < p > Reads incoming data from the connected USB device.</ p >
271+ < p > Returns:</ p >
272+ < p > A string containing the received data, or an empty string if no data
273+ is received before timeout.</ p >
274+ < p > 📤 Send Data</ p >
275+ < div class ="sourceCode " id ="cb19 "> < pre
276+ class ="sourceCode smallbasic "> < code class ="sourceCode smallbasic "> < span id ="cb19-1 "> < a href ="#cb19-1 " aria-hidden ="true " tabindex ="-1 "> </ a > n = usb.send(dat)</ span > </ code > </ pre > </ div >
277+ < p > Sends data to the connected USB device.</ p >
278+ < p > Parameters:</ p >
279+ < p > dat – The data to send as a string.</ p >
280+ < p > Returns:</ p >
281+ < p > The number of bytes successfully sent.</ p >
282+ < p > 📝 Example</ p >
283+ < pre > < code > import android
284+ usb = android.openUsbSerial(0x16C0)
285+ while 1
286+ input k
287+ n = usb.send(k);
288+ print "sent "; n
289+ print usb.receive()
290+ wend</ code > </ pre >
238291< h2 id ="how-to-edit-and-run-a-program "> How to edit and run a
239292program</ h2 >
240293< h3 id ="internal-editor "> Internal editor:</ h3 >
@@ -304,7 +357,7 @@ <h2 id="privacy-policy">Privacy Policy <a
304357< p > < a href ="privacy.html "> Privacy Policy</ a > </ p >
305358</ div >
306359 < div class ="pagefooter ">
307- This page was last edited on Mon, 7 Apr 2025 22:04:07 +0200
360+ This page was last edited on Mon, 7 Apr 2025 22:40:38 +0200
308361 |
309362 < a href ="https://en.wikipedia.org/wiki/Markdown " target ="_blank " rel ="nofollow "> Markdown</ a >
310363 processed with
0 commit comments