Shop OBEX P1 Docs P2 Docs Learn Events
flexBASIC P2 WiFi — Parallax Forums

flexBASIC P2 WiFi

I am now going to see how far I can get with flexBASIC WiFi.

I plugged in the WiFi module, and got the IP address, and now what?

I checked the Ports for P2, in flexprop, the WiFi IP does not show up. Is there any other way of connecting to the IP address and communicating with the P2. I was thinking along the lines of maybe using Telnet, to gain access. Anybody have any ideas?

Thanks
Ray

«1

Comments

  • I am getting this in the flexprop terminal, anybody know what this is.

    Ray

    ERROR: timeout waiting for initial checksum: got -1
    Try increasing the FIFO setting if not large enough for your setup
    Press enter to continue...
    
  • @Rsadeika said:
    I am getting this in the flexprop terminal, anybody know what this is.

    Ray

    ERROR: timeout waiting for initial checksum: got -1
    Try increasing the FIFO setting if not large enough for your setup
    Press enter to continue...
    

    Yes I know what it is, a P2 serial response character is failing to arrive and the code is timing out. A recent change to timeout computations in loadp2 might possibly have caused it if earlier versions of loadp2 were previously working okay.

    What type of system are you running, Windows or Mac or Linux, and is this the P2-EVAL system or a P2-Edge? I know I used to see differences between them in the past related to timeouts (even though they both use the FT231X chips if you have a recent PropPlug).

    Also check your DIP switches are setup correctly for serial access and try removing any SD card if one is fitted.

  • roglohrogloh Posts: 5,837
    edited 2021-10-19 01:33

    Also AFAIK flexprop doesn't support Wifi at this time (certainly its loadp2 does not). You still need a serial/PropPlug type of interface to work with loadp2. EDIT: It looks like flexprop actually now includes proploader which does support Wifi, though perhaps that's only for P1 use.

    Somewhat relatedly I've not been able to get PropTool on Windows to recognize an ESP-03 loaded with the VonSzarvas wx Wifi firmware either, even though the web interface is responding and presenting the HTML pages, however it is still early days. So I'm not sure what software is needed for using it for download/debug etc, and it could be just TELNET for a console. You might need the alternative propeller-load tool which I think is meant to support Wifi.

  • Yes, I have a P2-Edge setup and I am using Linux(Raspberry Pi). Flexprop does support WiFi for the P1, but I guess Parallax has not gotten around to having WiFi for everything.

    Ah yes, VonSzarvas wx Wifi firmware. I wonder why that has not been adapted for flexprop? Aside from the VonSzarvas wx Wifi firmware, I wonder if there is any other way of getting access to the WiFi via flexBASIC P2. At this point, I do not need the capability to program the P2 via WiFi, I just need someway to use the WiFi.

    I also have the uSD module plugged in, I wonder if that is creating a problem.

    Ray

  • Well I had many problems with downloading serially to the P2-Edge with older versions of loadp2 which drove me crazy and prompted me to dig down into it with the logic analyzer and make those recent changes to timeouts which fixed it for me on my Mac. (OS X 10.10). If you were using an older version of loadp2, you could try the latest loadp2 to see if it helps. You can get it from github here https://github.com/totalspectrum/loadp2 and compile for Linux.

    You could try removing the microSD card on your P2-Edge (must be a new rev C) to see if that improves anything and lets you download serially.

  • For the uSD problem, I had it plugged into P24 - p31 bank. I unplugged and plugged it into p16 - p22 bank, here it now does not cause the problem.

    As for the WiFi, I thought by creating a comm, telnet.startx(62, 63, 0, 115200), flexBASIC would be connecting to the WiFi module, and allowing some kind of comms between flexBASIC and a telnet connection. So far I am getting nothing on the telnet side. Should the baud rate be something other than 115200.

    I am using putty which does not allow a BAUD setting, or at least I did not notice it. Missing something on that point?

    Ray

  • dgatelydgately Posts: 1,631
    edited 2021-10-21 17:20

    I tested a small example flexBASIC program on P2 Edge & a Parallax Wifi module (hooked up to P56-P63 socket). After fiddling with telnet mods a bit (needed character mode and setting CRLF option), I got comms both ways between the P2 and a telnet session running on macOS (in the UNIX Terminal app)...

    telnet settings used:

    mode character
    set crlf
    set crmod
    
    '
    '  test a comm via Parallax WiFi Module in PropBASIC
    '
    '
    
    dim ser as class using "SmartSerial.spin"
    dim X
    
    ser.startx(63, 62, 0, 115_200)
    
    do
    
      pausems 10
    
      X = ser.rxcheck()
      if X > 0 then
          if X = 10 then
            ser.tx(13)
          else
            ser.tx(X)
          end if
      end if
    
    loop
    


    Start with this simple example... Once that works, start adding SD and other features.

  • On the WiFi module through the web page there are baud rate setting that would be used between the P2 and the WiFi Module. From the telnet or putty session there would be no baud rate as it is not a serial connection and does not have one.

    The WiFi module is doing the conversion from telnet to serial on the P2 and the baud rate must match which defaults to 115200 on the WiFi module.

    Mike

  • I got back to working with the Edge WiFi, and I noticed the blue LED was not flashing on the WiFi ESP8266 . So, something went wrong. I think I should be buying the Parallax WX WiFi ESP8266 SIP modules by the bushel basket. Not even sure if the one I have is now fixable. Their has to be a better solution for this.

    Ray

  • @Rsadeika said:
    I got back to working with the Edge WiFi, and I noticed the blue LED was not flashing on the WiFi ESP8266 . So, something went wrong. I think I should be buying the Parallax WX WiFi ESP8266 SIP modules by the bushel basket. Not even sure if the one I have is now fixable. Their has to be a better solution for this.

    Are you using: P2 WX Adapter Add-on Board
    SKU 64007? Or wiring the module with jumper wires? What is your full setup? I did buy 3 or 4 of the modules & adapters as I always assume that I’ll kill at least one😳

  • Yes I am using the P2 WX Adaptor Board. I found another WiFi SIP module, plugged it in, and I get a solid blue LED. Last time I used it, it was working.

    Now I am starting to wonder if the P2 Edge mini breakout board has a problem with it. I did mention that I was having a problem with uSD module, after I moved it to different socket the problem got fixed. Not sure what I will be doing next.

    Ray

  • Ray

    Now that you’re getting the blue LED, try the code from post #9…

  • RsadeikaRsadeika Posts: 3,837
    edited 2021-10-22 22:28

    Nope, it is a solid blue LED and not a flashing blue LED. A 192.168.4.1 does not come up, and whatever I had as an IP address does not show up either. So, this other WiFi SIP that I am trying is not functioning correctly, either.

    There are three items that are in play, the Edge mini board, WX Adaptor Board, and the WiFi SIP itself. I have to figure out how to check each item to see if it is working properly. I probably do not have the correct equipment for doing this.

    Ray

  • With an IP of 192.168.4.1 you unit is in SoftAP mode and not in Station mode to connect up to your home network.

    Mike

  • @Rsadeika said:
    Nope, it is a solid blue LED and not a flashing blue LED. A 192.168.4.1 does not come up, and whatever I had as an IP address does not show up either. So, this other WiFi SIP that I am trying is not functioning correctly, either.

    Hmm... My blue LED blinks twice quickly, waits about 2 seconds then repeats the 2 blinks, continuously. When I type text in telnet or the flexprop console, the input & output LEDS quickly blink.

    BTW: the module has a yellow power LED on the left side. Is that lit on yours? And, are you powering the P2 Edge with 5 volts?

    dgately

  • Solid Blue LED indicates the unit is in SoftAP mode. In Station Mode the LED blinks.

    Mike

  • @iseries said:
    Solid Blue LED indicates the unit is in SoftAP mode. In Station Mode the LED blinks.

    Mike, I always set mine to STA+AP mode... Is that appropriate for most use?

  • Just to verify that it is just the WiFi SIP module, I plugged it into a breadboard, and powered it up with 5.0 V. Same result, solid blue LED.

    Since it is in SoftAP, then it should be accessible via 192.168.4.1, but all of my different WiFi devices are not making contact with the WiFi SIP. It seems like my WiFi SIP module is stuck in SoftAP, and the unit is not turning on a WiFi signal. Not sure how to get around that, would be nice it it had a reset button.

    Ray

  • Interesting thing has occurred, the original WiFi SIP, where the blue LED was not turning on, now it has a flashing blue LED.

    I was getting ready to put it in my non functional units box, when I decided to plug it into the breadboard, with the 5.0 V power source. When the blue LED started to flash I then plugged into the WiFi adapter board, powered up the P2 Edge mini board, and the WiFi SIP is still flashing the blue LED.

    I am now scratching my head trying to figure out, what is going on, is the P2 Edge mini board having some kind of power issues. No idea what so ever.

    Ray

  • I sort of got the telnet part working.

    The spin/SmartSerial.spin works, but when you add:
    open SendRecvDevice(@teln.tx,@teln.rx) as #3
    the telnet does not respond. Since I do not have access to an input #x, I need an RxStr. Below, is a PUB that works in P1 but it does not work in P2.

    This is a snippet from the Martin Hebel Extended FullDuplexSerial.spin, but it does not work in P2. Can anybody can fix the problem so it will work with P2.

    PUB RxStr (stringptr) : Value | ptr
    {{
      Accepts a string of characters - up to 15 - to be passed by reference
      String acceptance terminates with a carriage return or the defined delimiter character.
      Will accept up to 15 characters before passing back.
      Serial.Rxstr(@MyStr)        ' accept
      serial.str(@MyStr)          ' transmit
     }} 
        ptr:=0
        bytefill(@dataIn,0,15)                               
       dataIn[ptr] :=  Rx        
       ptr++                                                  
       repeat while ((DataIn[ptr-1] <> 13) and (DataIn[ptr-1] <> Delimiter)) and (ptr < 15)       
           dataIn[ptr] :=  RX    
           ptr++
       dataIn[ptr-1]:=0                                         
       byteMove(stringptr,@datain,16)
    
  • Ray,
    Try this (not fully tested but it does allow string input from the telnet session):

    '
    '  test a comm via Parallax WiFi Module in PropBASIC
    '
    '  Use telnet to open a session with the IP of the module
    '  Use these telnet settings (only on macOS?):
    '      mode character
    '      set crlf
    '      set crmod
    '
    
    dim ser as class using "SmartSerial.spin"
    dim X
    dim a$ as string 
    dim p as integer
    
    a$ = "1234567890123456789012345678901"
    
    ser.startx(63, 62, 0, 115_200)
    
    ''open SendRecvDevice(@ser.tx,@ser.rx,0) as #3
    
    do
    
      pausems 10
    
      RxStr(a$)
      ser.str("You typed: ")
      ser.str(a$)
    
    loop
    
    
    sub RxStr(xx as string)
    
      p = 0
      bytefill(xx, 0, 30)
      xx[p] = ser.rx()
      p += 1
    
      do while (xx[p-1] <> 13) AND (p < 30)
    
        xx[p] =  ser.rx()    
        p += 1
      loop
    
      xx[p-1] = 0 
     '' byteMove(stringptr,@datain,31) 
    
    end sub
    
  • I am having a very hard time dealing with telnet. I only have two choices, TeraTerm or putty, and both are very hard to deal with, at least for me.

    Now I am wondering if their is another way that is available?

    Ray

  • how about windows telnet?

    Part of windows (you may need to check the checkbox in windows features)

    Mike

  • dgatelydgately Posts: 1,631
    edited 2021-10-25 23:34

    @Rsadeika said:
    I am having a very hard time dealing with telnet. I only have two choices, TeraTerm or putty, and both are very hard to deal with, at least for me.

    Now I am wondering if their is another way that is available?

    You can run telnet on your Raspberry Pi…

    $ sudo apt install telnet
    

    Then:

    $ telnet [the IP of your WiFimodule]
    Trying 10.0.0.nnn…
    Connected to 10.0.0.nnn.
    Escape character is ‘^]’
         <== I type Control-] here to allow input of ‘set’ and ‘mode’ changes
    ABCD…
    
  • I am having some trouble with the program below. It seems to not run with the warnings being shown.

    I am not sure if the program is not running because of the warnings or because the program is not correct. Not sure what to make of
    warning: assignment to const item. I do not know how to get around this.

    Ray

    '''''''''''''''''''''''''''''
    ' test_usd.bas
    '
    ' Month Day, Year
    '''''''''''''''''''''''''''''
    
    
    ' Compiler directives
    'OPTION BASE 0    'all array indexes start at ZERO, not one.
    'OPTION EXPLICIT      'formal declaration of all vars is required.                      
    
    '''''''''''''''''''''''''''''
    ' Constants
    'const HEAPSIZE = 8192
    'CONST _clkfreq = 180_000_000
    
    '   CLASSes
    dim ser as class using "spin/SmartSerial.spin"
    
    
    '   Member Variables
    'dim inBuff$ as string
    dim X
    dim a$ as string 
    dim p as integer
    
    a$ = "1234567890123456789012345678901"
    
    
    '''''''''''''''''''''''''''''
    
    'Comms
    ser.startx(63, 62, 0, 115200)
    'open SendRecvDevice(@teln.tx,@teln.rx) as #3
    
    '''''''''''''''''''''''''''''
    
    '' Filesystem
    'mount "/host", _vfs_open_host()
    'mount "/sd", _vfs_open_sdcardx(3, 2, 5, 6)
    
    
    '' Main Program loop
    ser.str(a$)
    
    do
    
    
    
        pausems 10
    
      RxStr(a$)
      ser.str("You typed: ")
      ser.str(a$)
    
    loop
    
    end
    '''''''''''''''''''''''''''''
    
    '' Subroutines
    sub RxStr(xx as string)
    
      p = 0
      bytefill(xx, 0, 30)
      xx[p] = ser.rx()
      p += 1
    
      do while (xx(p-1) <> 13) AND (p < 30)
    
        xx[p] =  ser.rx()  
        p += 1
    
      loop
    
      xx[p-1] = 0 
     '' byteMove(stringptr,@datain,31) 
    
    end sub
    
    '''''''''''''''''''''''''''''
    
    
    "/home/pi/flexprop//bin/flexspin" -2 -l --tabs=2 -D_BAUD=230400 -O1    --charset=utf8 -I "/home/pi/flexprop/include"  "/home/pi/programs/flexprop/P2_Edge_wifi_test/test_uSD/test_usd.bas"
    Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2021 Total Spectrum Software Inc.
    Version 5.9.4-HEAD-v5.9.3-38-g05394b22 Compiled on: Oct 24 2021
    /home/pi/programs/flexprop/P2_Edge_wifi_test/test_uSD/test_usd.bas:66: warning: assignment to const item
    /home/pi/programs/flexprop/P2_Edge_wifi_test/test_uSD/test_usd.bas:71: warning: assignment to const item
    /home/pi/programs/flexprop/P2_Edge_wifi_test/test_uSD/test_usd.bas:76: warning: assignment to const item
    test_usd.bas
    |-SmartSerial.spin
    test_usd.p2asm
    Done.
    Program size is 2916 bytes
    Finished at Tue Oct 26 08:19:38 2021
    /etc/alternatives/x-terminal-emulator -T "Propeller Output -p /dev/ttyUSB0" -e "/home/pi/flexprop//bin/loadp2" -p /dev/ttyUSB0 -b230400 "/home/pi/programs/flexprop/P2_Edge_wifi_test/test_uSD/test_usd.binary" "-9/home/pi/programs/flexprop/P2_Edge_wifi_test/test_uSD" -k
    
    
  • @Rsadeika said:
    I am having some trouble with the program below. It seems to not run with the warnings being shown.

    I am not sure if the program is not running because of the warnings or because the program is not correct. Not sure what to make of
    warning: assignment to const item. I do not know how to get around this.

    Although I like to work towards solving the warnings eventually, this is just a prototype example to make sure your WiFi module is able to communicate with a telnet session. This example worked with the setup I described several posts back. I actually tested using a MacBook Pro to get it running. But, I also ran telnet on a Raspberry Pi just to be sure I could communicate via WiFi from there as well!

    I assume the output you pasted here is from the flexprop main window. What shows up in your flexprop terminal when you run this?

  • This is interesting, on my setup, it seems like nothing is working as expected. But on your MacBook it seems to be working as expected. Not sure what to make of this. I must be doing something terribly wrong.

    I will keep hacking at this, but it seems like this is not worth the effort, I mean working with telnet, for this situation.

    I did a simple program, just using ser.rx(), and that does seem to work.

    I updated flexprop to 5.9.4, could their be some problem there.

    Ray

  • dgatelydgately Posts: 1,631
    edited 2021-10-27 18:16

    I don't think flexprop is the problem (it compiles other code, I assume? It loads the P2 board & runs other binaries?). i.e. if you can compile/load/run the simple blink1.bas or blink1.spin2 example from flexprop's samples directory, flexprop is good to go.

    Are you setting up (plugging in) the WiFi module as shown in the images I posted? When powered are you able to bring up the WiFi Module's webpage in a web browser that is on the same network? (my network IPs are something like: 10.0.0.nnn, where 'nnn' is unique to a particular WiFi Module). If so, what are the modules settings?

    Steps to debug just the ability for telnet to find and communicate with the WiFi Module:
    1. Ability of flexprop to compile/load/run code samples
    2. WiFi Module is powered and the blue LED is blinking (if lit but not blinking, it is in AP-ONLY mode, which is not what you want)
    3. The WiFi Module has an IP number other than 192.168.4.1 (meaning it is in a 'STA' mode or 'STA+AP' mode)
    4. The WiFi Module's webpage is accessible in a web browser. You may need to use 192.168.4.1 to initially get to the Module's webpage, but change to STA or STA+AP mode and setup the module to gain a local IP number.

    5. Use telnet (on macOS or Linux... Not sure about WIN) $ telnet the.local.IP.number
    6. If telnet appears to have found the module, type some text and see if the module's rx & tx LEDs flash

    If you can get that far, you can start to debug the .spin2 code!

  • Thanks dgately, for all the information and assistance. Hopefully I will get there at some point.

    Ray

Sign In or Register to comment.