// FILE: scilabPcSerialToNxt0_1a.sce - Work
// DATE: 04/01/20 09:05
// AUTH: P.Oh
// DESC: PC USB RS485 to NXT.  Scilab iterates counter and transmits serially to NXT
//       Receiving NXT will then transmit to Slave via Bluetooth
//       Thinkpad (COM 10).  Use Windows Device Manager to check COM port #
//       and baud settings. Scilab version 6.1.0 so run loader.sce to update Serial Toolbox
//       Transmit integers 1 to 100

h = openserial(10,"4800,n,8,1"); // initialize PC's serial port
i = 0

while i <=30 
    disp(i); // show counter in PC's console
    strI = string(i); // Scilab's version of Num2Str
    writeserial(h, strI); // transmit serially to Master NXT
    i = i + 1; // update counter
    sleep(1000)
end
disp("All done!");

/*
// writeserial(h, "#02"+ascii(13))
writeserial(h, "Hello There"+ascii(13))
// writeserial(h, " 128, 256")
sleep(200)
// buf[] = readserial(h)
// sleep(5000)
*/

closeserial(h)
