// FILE: scilabPcSerialToNxt0_1b.sce - Works!
// DATE: 04/01/20 10:08
// 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
// VERS: 0_1a: prototyping
//       0_1b: Iterates from 0 to 30
// REFS: Works with Master NXT running btAndSerialMaster0_1b.nxc
//       and Slave NXT running btAndSerialSlave0_1b.nxc

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); // 1 sec enough time to flush port.  Set Wait in NXC Master and Slave at this rate
end
*/

strI = " -123, +456";
writeserial(h, strI); // transmit serially to Master NXT
disp(strI);
sleep(200);

disp("All done!");

closeserial(h)
