Using PICO from the Command Prompt

Posted on
  • So it seems i was able to send a command to the Pico from the Command Prompt in Windows 10. However the echo response does not occur. So the command is able to execute fine and it appears, however without a functioning echo, the return equations are not visible, only the hardware that has adjusted from the command

    here is what i have so far:

    C:\>echo LED2.set() > \\:\COM4
    

    this does in fact turn on LED 2. however i get no response to the prompt. If i change the command to 1+3
    i dont see the =4 until i attach the device to the WEB IDE

    i have also used:

    C:\>mode Com4: 96,N,8,1
    

    to set the baud rate. which after i can confirm with

    C:\>mode
    

    that is correct

  • Thr 2019.06.27

    Hello @Skog,

    'i dont see the =4 until i attach the device to the WEB IDE'

    This would be normal, as the only way the Pico is able to communicate with the WebIDE is via the attached USB cable.

    Not entirely sure what the intent is, but the function echo() has one parameter and takes an argument of T or F

    http://www.espruino.com/Reference#t_l__g­lobal_echo

     

    A call to a function in Espruino will return 'undefined' (or the intended return value of that function) unless other content you provide in a wrapper function you create is set:

    https://www.espruino.com/FAQ#when-i-type­-a-command-why-does-espruino-print-undef­ined-

    By chance is the intent to have something show up in the WebIDE after the LED is intentionally turned on?

    This tutorial example should assist in laying out the code:

    https://www.espruino.com/Pico+Buttons
    https://www.espruino.com/Control+LED+wit­h+Button
    https://www.espruino.com/Tutorials



    EDIT:
    It just dawned on me, as there isn't a mode() function in Espruino, that an attempt to pass DOS command line instructions is being used. Again, please explain the intent. Some posted code would assist here also.

  • @Skog, if you have a background process in your background window going that captures the input from same com port and pipes it to your command prompt window, you should be able to see the response. I'm not that much a win user anymore, but it is not much different as in linux/osx/...

  • Use the programme putty.

    Or use the web ide.

    Why do you want to write directly to the com port?

  • the DOS pass command is where the problem lays. My echo inside the IDE is working fine. However I can not see anything from the Espruino with Command Prompt - i can only call the command (one way)

    @Wilberforce, it frees up access to talk with other devices.

  • @Robin, @Skog is trying to do this: http://www.espruino.com/Interfacing#wind­ows

    @Skog what you're doing looks good to me, however the command:

    C:\>echo LED2.set() > \\:\COM4
    

    Isn't going to receive anything from the board - the > is telling windows you're just writing to COM4 and not reading from it.

    As @allObjects says, in Linux/Mac you generally have another process running that's piping from the COM port in the background, but I'm not sure how that works in Windows.

    Ok, I just googled it. Not tried it but there's a bunch of stuff out there as this is something people often do with Arduino by the look of it:

    https://stackoverflow.com/questions/1948­9733/batch-file-receive-data-from-the-se­rial-port-and-write-it-into-txt-file

    So:

    mode COM4 BAUD=9600 PARITY=n DATA=8
    echo yourCommand() >COM4
    COPY COM4 data.txt
    

    Will pipe the data to a file until the Pico sends a Ctrl-Z character ("\x1A")

    Or I believe:

    mode COM4 BAUD=9600 PARITY=n DATA=8
    echo yourCommand() >COM4
    set /p line=<COM4
    

    May work for a single line. However you may end up just getting the end of the line that is the command, as Espruino will echo back the command that is sent to it unless echo(0) has been called or there's a special char at the beginning of the line. Check out the NOTE: right at the top of http://www.espruino.com/Interfacing

    Also it's worth checking your MODE command as it looks like you're trying to set the baud rate to 96, not 9600. Over USB it may not matter, but 96 is super slow (10 chars per second :) and may not even be supported on some PCs/adaptors.

    To be honest past a certain point you may find it's easier/more reliable to use a Python script to get your data and to then call that from the command prompt: http://www.espruino.com/Interfacing#pyth­on-multiplatform-

  • @Gordon

    the > of the code simply sends the command. I switched it to = and found i received an echo - only it was inside the VT - it did not get its info from the device. --btw 96 is an abbreviated condition for 9600 bps, however your observation about it being a USB could be correct because the rate can be anything for sending the command. So i wonder if the VT has to be configured for a USB? Is there away to make it trainable to work with Espruino? I will probably avoid using Python and stay with the straight forward VT/or/VS

  • Can you try sending the command echo(0) and then sending USB.println("Hello") or similar? As I'd said above the REPL adds a bunch of other junk and that could be throwing you off.

    Honestly at this point it sounds like you know more than me about it - I'm not sure there's much I can add really. I'd doubt there is much difference between USB and standard COM ports though.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Using PICO from the Command Prompt

Posted by Avatar for Skog @Skog

Actions