Notice that I point the Spin Compiler field in the Properties to a copy of fastspin (I keep all my propeller tools in the /opt/parallax/bin/ directory for ease of updating them, quickly, in one place). No need to rename openspin to fastspin. That way it's easy to switch between them!
dgately
Oh, i didn't know simpleIDE would accept a different spin compiler,,,,,hmm.. nice...
oh man, so im gonna have to git a different head and give that a try to see it it still shows that problem...
hmm.. think i'll steam up a cup a joe...
Perhaps its the newer QT5.11 that broke it?
Or should I have compiled GCCv6 instead of GCCv4?
So many options...
I suppose now I need to parse the build log....
Compiling v 1.1.0 didn't change anything.
This must be a QT5.4 vs QT5.11 problem.
Hmm. ..sinking in c quicksand..
I don't even need the compiler options, actually, but I want to be able to make it proper if I am going to share it.
I don't own a P2, and so I don't have an immediate need for the p2 compiler switch.
But I'd still like to fix it, since i have been wanting to get into the qt ide for a while now, its nice to have a reason to use qt, and now i do.
I will now install the parallax older version and see if it even accepts the switch.
That will get me closer to knowing if its a os or build environment version issue.
SimpleIDE from the parallax site linux v1.0.1 RC1 does this also for me. Hmm could this be linux only?
Well, i can compile a raspberrypi version and try it.
I can make a mac one too, but i can't test it.
I have updated/populated much more information here, and have reached a point that I will not add a whole lot more.
When I do add more I don't usually make another post, so the thread will not show up at the top.
So check back if the content interests you, it may improve!
Since it contains so much info, parallax customers might benefit by making it sticky status.
Or if parallax wants to hack this thread up and turn it into an official sticky more to their liking, DO IT.
Just let me keep my copy, so i can change it when things change(like when people change repos that break these instructions)
If anyone wants to copy the info here and use it somewhere else, DO IT.
All this info was made from parsing the interwebz and help/info from forum users!
I may at one point create a windows version, but not now.
PropGCC needs to be updated, and most peeps involved know that, and I suspect it will be updated for the P2.
QT5.11 causes code issues in older code, which needs to also be updated, I don't what the status is on that.
Since I am getting into working in QT, I will keep this thread updated if I learn more things about it or the SimpleIDE code.
I hope this info helps someone!
It helps me all the time when I want to re-do my system, and forget all the steps to get to the ability to compile SimpleIDE.
Lots of steps involved!
The latest verion will give you a "configure: error: could not find bash >= 3.1"
To fix:
Change line 193 at: esp-open-sdk/crosstool-NG/configure.ac
like this:
|$EGREP '^GNU bash, version ([0-9\.]+)')
then run make again
It would be better to edit the configure.ac file as suggested, to avoid permission issues, but....
I have attached the fixed file. Change its name to configure.ac (remove the .txt) It goes into esp-open-sdk/crosstool-NG/
If you ever run the make as root, you will need to remove the esp-open-sdk folder completely, and then re GET it, and then change/download the configure.ac file again and overwrite the one in esp-open-sdk/crosstool-NG/ ...don't run as su/sudo.
If any more errors are discovered in this compile process I am doing today, I will edit this post with the fixes.
I will be compiling my own custom esp webpage for my parallax WXesp8266 device.
To use as a wireless model railroad engine controller.
I ran through the first set of compiling, I stopped at the part that starts to prepare code for the compile of, SimpleIDE.
(propGCC and the rest) Since support for SimpleIDE is getting stale, I will not do that part.
I changed the colors by editing /Parallax-ESP/html/style.css (i changed the backgrounds to black, and added a text style for white text.,
I changed the /Parallax-ESP/html/logo.png to match my locomotive image.
I also changed the /Parallax-ESP/html/favicon.ico to match my loco. favicon.ico MUST be 32 pixel X 32 pixel or 16 X 16.
I am pretty sure the favicon.ico can be .PNG format that was simply renamed to a .ICO file format.
I changed the titles in the /Parallax-ESP/html/index.html page to my locomotives title for the "home" page.
It doesn't show my module information because I am running the html locally, not on the esp yet for testing the html changes.
The spin code that will run on the propeller, will need more time to create, because I will need to covert all the C code in the header files and the main file to spin.
This is why I created this thread, to let users, and myself, be able to change the looks of their WX webpage, even if they forget how to do it all years later, they can come to this thread and do it again.
As I complete the html code, and spin code, I will post the entire example here in this single post.
(I will edit this and add it.)
When you first access the Parallax Wx esp 8266 module, using the LAN name doesn't work that well if you are connected to the internet also, or any other network.
The first time you access it, you should use http://192.168.4.1 as the address.
If you connect it to your network, then you will need to find its IP address and access it using that address.
BEWARE, if you put files that take up too much space in your Parallax-ESP/html folder, you will get this error.
/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: build/httpd.user1.out section `.irom0.text' will not fit in region `irom0_0_seg'
collect2: error: ld returned 1 exit status
make: *** [Makefile.ota:51: build/httpd.user1.out] Error 1
For me, my logo.png was too large. I could also change my file format to GIF to preserve transparency.
I colored my transparency to match my webpage background color, and saved it as a JPG with high compression. (like 50%)
I also had to change the index.html to match it.
<img src="logo.jpg">
Don't forget to change ALL HTML files in all folders when you change things because some files have identical content.
For my logo to work I had to change all logo.png to logo.jpg in;
index.html, log.html, newpage.html, settings.html, update-ffs.html.
I also had to change the
Parallax-ESP/html/flash/index.html, and
Parallax-ESP/html/websocket/index.html, and
Parallax-ESP/html/wifi/wifi.html, and
Parallax-ESP/html/wifi/connecting.html
You can see that the WX device uses multiple locations to store many files, like index.html.
If your webpage changes are not taking, you most likely missed updating the change also
in the main /Parallax-ESP/html/ folder and its subfolders, flash, websocket, and wifi.
If your internet is getting messed up when you connect to your Parallax WX esp8266
(If you can't access the web anymore, if you have TWO wifi devices or have a wired internet)
Set your wifi device IP address that accesses the ESP device to 192.168.4.2, this is only for AP mode.
If you changed the IP of your ESP device and you are still accessing it in AP mode you can try adding 1 to the ip that the esp device uses, and put that as your wifi devices IP.
Here is a wave file audio demo you can run with your Propeller Activity Board WX with the Parallax WX esp8266 wifi device attached also.
It is all written in spin.
Plug in a pair of headphones or speakers to hear it.
You will see the WX audio output LEDS light up during the audio.
You can read the output of the text with PUTTY connected to the WX's ip address using port 23. (telnet)
The demo uses Raymond Allens SPIN wav player.
I had to modify it to show text output to putty over the wifi instead of TV
It was also modified to use the proper pins for audio and the sd card, for the Activity Board Wx.
Make sure the format on the sd card is FAT (fat16)
Put the 4 wav files on your micro sd card, and put the card into the Activity Board Wx sd slot.
The .wav file format is: PCM 16.000kHz 16bits mono.
Connect to the WX board using wifi, upload the program using SimpleIDE or FlexGUI.
(FlexGUI will automatically load a terminal to view the telnet output when you upload the program to the propeller)
You will hear the BORG queen from start trek next generation.
You can hear the other wave files by removing the ' symbol shown below in front of the one you want to hear
Make sure to put a ' in front of the one that doesn't have one when you change it.
'i:=sd.popen(string("test1.wav"), "r") ' <--------- Change .wav filename here !!!!!!!!!!!!!!
'i:=sd.popen(string("test2.wav"), "r") ' <--------- Change .wav filename here !!!!!!!!!!!!!!
'i:=sd.popen(string("test3.wav"), "r") ' <--------- Change .wav filename here !!!!!!!!!!!!!!
i:=sd.popen(string("test4.wav"), "r") ' <--------- Change .wav filename here !!!!!!!!!!!!!!
Start putty and connect to your WX esp IP using telnet port 23, in putty, before you upload the program.
' SPIN WAV Player Ver. 1a (Plays only mono WAV at 16ksps)
' Copyright 2007 Raymond Allen See end of file for terms of use.
CON _clkmode = xtal1 + pll16x
_xinfreq = 5_000_000 '80 MHz
buffSize = 256
Tx = 30 'serial out to wx device
Rx = 31 'serial in from wx device
VAR long parameter
long buff1[buffSize]
long buff2[buffSize]
long stack1[100]
word MonoData[buffSize]
OBJ
text : "FullDuplexSerial"
SD : "FSRW"
PUB Main|n,i,j
'Play a WAV File
'Start up the status display...
text.start(Rx,Tx,0,115_200) 'Start the text driver (uses another cog)
waitcnt(80_000_000 + cnt) 'Wait for 1 s
text.str(string(27)) 'Set command mode ANSI command for putty terminal program.
text.str(string("[2J")) 'Clear telnet screen.
text.str(string(27)) 'Set command mode
text.str(string("[1;1f")) 'Set Position
text.str(string("Starting Up",10,13))
'open the WAV file (NOTE: Only plays mono, 16000 ksps PCM WAV Files !!!!!!!!!!!!!)
'access SD card
i:=sd.mount(22)
waitcnt(80_000_000 + cnt) 'Wait for 1 s
'
if i == 0
text.str(STRING("SD Card Mounted",10,13))
else
text.str(STRING("SD Card Mount Failed",10,13))
repeat
'open file
'i:=sd.popen(string("test1.wav"), "r") ' <--------- Change .wav filename here !!!!!!!!!!!!!!
'i:=sd.popen(string("test2.wav"), "r") ' <--------- Change .wav filename here !!!!!!!!!!!!!!
'i:=sd.popen(string("test3.wav"), "r") ' <--------- Change .wav filename here !!!!!!!!!!!!!!
i:=sd.popen(string("test4.wav"), "r") ' <--------- Change .wav filename here !!!!!!!!!!!!!!
waitcnt(80_000_000 + cnt) 'Wait for 1 s
If i == 0
text.str(STRING("File Open Successful",10,13))
else
text.str(STRING("File Open Failed",10,13))
repeat
'ignore the file header (so you better have the format right!)
'See here for header format: http://ccrma.stanford.edu/CCRMA/Courses/422/projects/WaveFormat/
i:=sd.pread(@MonoData, 44) 'read data words to input stereo buffer
waitcnt(80_000_000 + cnt) 'Wait for 1 s
text.str(STRING("Header Read ",10,13))
'Start the player in a new cog
COGNEW(Player(26, 27),@stack1) 'Play runs in a seperate COG (because SPIN is a bit slow!!)
waitcnt(80_000_000 + cnt) 'Wait for 1 s
text.str(STRING("Playing...",10,13))
'Keep filling buffers until end of file
' note: using alternating buffers to keep data always at the ready...
n:=buffSize-1
j:=buffsize*2
repeat while (j==buffsize*2) 'repeat until end of file
if (buff1[n]==0)
j:=sd.pread(@MonoData, buffSize*2) 'read data words to input stereo buffer
'fill table 1
repeat i from 0 to n
buff1[i]:=($8000+MonoData[i])<<16
if (buff2[n]==0)
j:=sd.pread(@MonoData, buffSize*2) 'read data words to input stereo buffer
'fill table 1
repeat i from 0 to n
buff2[i]:=($8000+MonoData[i])<<16
'must have reached the end of the file, so close it
text.str(STRING("Closing... ",10,13))
sd.pclose
waitcnt(80_000_000 + cnt) 'Wait for 1 s
text.str(STRING("Closed. ",10,13))
'shut down here
PUB Player(PinR, PinL)|n,i,nextCnt,j
'Play the wav data using counter modules
'although just mono, using both counters to play the same thing on both left and right pins
'Set pins to output mode
DIRA[PinR]~~ 'Set Right Pin to output
DIRA[PinL]~~ 'Set Left Pin to output
'Set up the counters
CTRA:= %00110 << 26 + 0<<9 + PinR 'NCO/PWM Single-Ended APIN=Pin (BPIN=0 always 0)
CTRB:= %00110 << 26 + 0<<9 + PinL 'NCO/PWM Single-Ended APIN=Pin (BPIN=0 always 0)
'Get ready for fast loop
n--
i:=0
j:=true
NextCnt:=cnt+1005000
'Play loop
'This loop updates the counter with the new desired output level
'Alternates between buff1 and buff2 so main program can keep buffers full
repeat
repeat i from 0 to buffSize-1
NextCnt+=5000 ' need this to be 5000 for 16KSPS @ 80 MHz
waitcnt(NextCnt)
if (j)
FRQA:=buff1[i]~
FRQB:=FRQA
else
FRQA:=buff2[i]~
FRQB:=FRQA
NOT j
DAT
{{
TERMS OF USE: MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
}}
The zip file contains all the files needed.
It also contains the .side file for SimpleIDE
The wx settings are also shown.
The Activity Board WX needs to have DTR (gpio12) RESET pin set to program the propeller, on the settings web page. (see image)
I also tie the SEL pin high (3.3v) with a 1k resistor to force the use of the WIFI interface. (sometimes the USB will be activated, even when I don't have usb connected)
I have updated the compile process of Parallax-ESP because the latest commit fails build, due to a change in the code,
its using a different repo for 'esp-open-sdk' and I don't know yet or may never know how to fix the compile process.
So I changed the instructions to use the previously working head, i will post changes if the new change is fixed / or compile instructions are discovered.
The next few posts have the files needed to program an ESP with Parallax-ESP firmware.
Here is the windows Flash-all.bat script.
@echo off
ECHO Filename: Flash-all.bat
ECHO THIS WILL Flash the firmware and clear out all settings and the user flash filesystem.
ECHO IT LOOKS ON COM1 FOR THE ESP. YOU MUST SET YOUR COM PORT FOR THE PROPPLUG IN THE DEVICE MANAGER, OR IN THIS FILE TO MATCH.
ECHO THIS BATCH WILL ATTEMPT TO SET THE PORT SPEED. YOU MAY NEED TO SET THE COM PORT SPEED SETTING IN THE DEVICE MANAGER TO THE SAME IN THIS FILE 115200.
ECHO SET YOUR FLASH SIZE TO EITHER 1M, 2M or 4M, IT IS CURRENTLY SET AS 2M.
ECHO TO STOP Press CTRL-C, Then Answer with a CAPITAL Y, Otherwise press any key to continue.
PAUSE
set PORT=COM1
set BAUD=115200
REM Currently supported methods are: none, ck, nodemcu, wifio.
set BOARD=none
REM <512K|256K|1M|2M|4M|8M|16M|32M>
set FLASH_SIZE=2M
REM <40|26|20|80>
set FLASH_SPEED=80
REM <qio|qout|dio|dout>
set FLASH_INTERFACE=qio
set FLASH_BLOCK_SIZE=1024
set BOOT_LOADER=0x000000
set USER1_IMAGE=0x001000
set USER_SETTINGS1=0x07E000
set USER_SETTINGS2=0x07F000
REM Flash filesystem base
set FFS_BASE=0x100000
if %FLASH_SIZE%==1M goto :Flash1M
if %FLASH_SIZE%==2M goto :Flash2M
if %FLASH_SIZE%==4M goto :Flash4M
if %FLASH_SIZE%==8M goto :Flash8M
if %FLASH_SIZE%==16M goto :Flash16M
if %FLASH_SIZE%==32M goto :Flash32M
:Flash1M
set WIFI_SETTINGS1=0x0FC000
set WIFI_SETTINGS2=0x0FE000
set WIFI_SETTINGS3=0x0FA000
goto Go
:Flash2M
set WIFI_SETTINGS1=0x1FC000
set WIFI_SETTINGS2=0x1FE000
set WIFI_SETTINGS3=0x1FA000
goto Go
:Flash4M
set WIFI_SETTINGS1=0x3FC000
set WIFI_SETTINGS2=0x3FE000
set WIFI_SETTINGS3=0x3FA000
goto Go
:Flash8M
echo Unsupported flash size! %FLASH_SIZE% exit 1
:Flash16M
echo Unsupported flash size! %FLASH_SIZE% exit 1
:Flash32M
echo Unsupported flash size! %FLASH_SIZE% exit 1
:Go
set tt0=-v
set tt1=-cp %PORT%
set tt2=-cd %BOARD%
set tt3=-cb %BAUD%
set tt4=-bz %FLASH_SIZE%
set tt5=-bf %FLASH_SPEED%
set tt6=-bm %FLASH_INTERFACE%
set tt7=-ca %BOOT_LOADER%
set tt8=-cf boot_v1.7.bin
set tt9=-ca %USER1_IMAGE%
set tt10=-cf httpd.user1.bin
set tt11=-ca %USER_SETTINGS1%
set tt12=-cf blank.bin
set tt13=-ca %USER_SETTINGS2%
set tt14=-cf blank.bin
set tt15=-ca %WIFI_SETTINGS1%
set tt16=-cf esp_init_data_default_v08.bin
set tt17=-ca %WIFI_SETTINGS2%
set tt18=-cf blank.bin
set tt19=-ca %WIFI_SETTINGS3%
set tt20=-cf blank.bin
set tt21=-ca %FFS_BASE%
set tt22=-cf blank.bin
Mode Com1: Baud=%BAUD% Parity=N Data=8 Stop=1
call esptool.exe %tt0% %tt1% %tt2% %tt3% %tt4% %tt5% %tt6% %tt7% %tt8% %tt9% %tt10% %tt11% %tt12% %tt13% %tt14% %tt15% %tt16% %tt17% %tt18% %tt19% %tt20% %tt21% %tt22%
PAUSE
unOFFICIAL v1.9b1 TESTING, USE AT YOUR OWN RISK.
This version nuumber is of my own creation so the latest compile doesn't conflict with 1.2
(the version on the HOMEPAGE of the module will show 1.9b1, if its above that, it will not work with proploader.)
This has all the updates to the firmware since the first release 1.0 and the release 1.2
New functions:
1) Can hide and unhide the WiFi module from the programmer without rebooting module.
2) Can set IP address, Gateway, Mask and DNS server.
3) Can send and receive UDP packets.
See the release-notes.txt file for all the updates included in this firmware.
Ok heres a zip with all the files needed for linux users or windows users to flash an esp to PARALLAX.
It also contains the OTA file for over the air updates (only for modules with 2MB or more of flash.)
Linux users, run ./flash-all.sh
Windows users, run Flash-all.bat
MY OWN TESTING HAS FOUND THIS:
This release of Parallax-ESP has a known bug, when first accessing the WIFI page, the module will crash and the wifi page will go white, just reload the wifi page again and configure as needed. This happens every time the module is first turned on and the wifi page is accessed.
It also seems to have a hard time connecting the first 3 tries or so, it just needs to warm up like a car.... ;)
Use it at your own risk.
If you like parallax's ESP open source code, and the ability to download programs via WIFI to your mcu, SUPPORT PARALLAX.
Purchase a PropPlug to flash an ESP8266 --> https://www.parallax.com/product/32201
And purchase a Parallax WX ESP8266 WiFi Module - SIP --> https://www.parallax.com/product/32420s
SUPPORT PARALLAX, DON'T BE A LEECH! (lol)
To use an OFFICIAL very old v1.0 version see 2 posts down.
I RECOMMENDED USING THIS VERSION. (v1.9b1 is not fully tested)
It is all the updates since, and including OFFICIAL v1.0, up to OFFICIAL v1.9b1.
It contains MANY features like: Updating the DNS with the HOSTNAME of the module, support for the BADGE, and the ability to choose the PIN NUMBER of the RESET LINE, and also the ability to enable/disable the DEBUG PIN, plus many more things, LOADER BAUD RATE...etc... to name a few, many more, see the release-notes.txt file for all the updates included in this firmware.
A zip with all the files needed for linux users or windows users to flash an esp to PARALLAX.
It also contains the OTA file for over the air updates (only for modules with 2MB or more of flash.)
Linux users, run ./flash-all.sh
Windows users, run Flash-all.bat
If you like parallax's ESP open source code, and the ability to download programs via WIFI to your mcu, SUPPORT PARALLAX.
Purchase a PropPlug to flash an ESP8266 --> https://www.parallax.com/product/32201
And purchase a Parallax WX ESP8266 WiFi Module - SIP --> https://www.parallax.com/product/32420s
SUPPORT PARALLAX, DON'T BE A LEECH! (lol)
Parallax has the 2016 OTA and other files available to downgrade it on their product download pages.
I posted this copy here because it contains the files: esptool-ck (esptool.exe and linux esptool) needed to run the flash-all.sh and flash-all.bat. The official download does not include the esptool-ck file.
That page's download contains all the files to use so you can also program the original files if you want to revert back to parallax's 2016 release.
Just replace the files with that 2016 release and flash.
For windows users to downgrade, the original files need to be renamed to the new names in the new zip so the BAT file can find them.
If you need help, ask here.
OR you can download the attached file, I did it all for you.
I have uploaded a zip file that contains the 2016 files to downgrade your esp.
It works just like the one above, except with the 2016 files, and the correct batch file names.
I also included esptool for both linux and windows, and corrected the linux scripts so they execute the esptool with a "./esptool".
I did not touch the original 2016 esp files.
I included this so windows users could also program an esp, (the original parallax download didn't have a way for windows users to do this.)
If you like parallax's ESP open source code, and the ability to download programs via WIFI to your mcu, SUPPORT PARALLAX.
Purchase a PropPlug to flash an ESP8266 --> https://www.parallax.com/product/32201
And purchase a Parallax WX ESP8266 WiFi Module - SIP --> https://www.parallax.com/product/32420s
SUPPORT PARALLAX, DON'T BE A LEECH! (lol)
Please note, these ESP modules HAVE LIMITED CONNECTIVITY.
What this means is they DO NOT PROVIDE internet and other advanced services that a typical router will provide.
In windows you will get this "error" saying the "connection was unsuccessful," in AP mode, or AP/STA mode.
Notice how it says the connection was unsuccessful, but then it contradicts its self and says it has limited connectivity.
Well, which is it Microsoft? Don't even get me started on that company and the creator of it.
I've been dealing with that garbage since DOS3.11
Don't believe a word of it, just connect to your module at Http://192.168.4.1
(yes you can click this link if your module is currently connected, and it will show the parallax module config page.
BEWARE your PROP will restart if you change the servo pwm too fast.
Tie the servo ground close to the power supply, not near the prop.
Like as if the prop ground is on a different branch than the servo.
That worked for me.
This loop runs really fast, so if you have good wiring to your servo and your prop doesn't reset, you CAN change the pwm pretty fast.
''*''**************************************************************
''* Putty Telnet Wireless WX Page Controls Servo Host Demo *
''* Author: Clock Loop @ parallax forums *
''* Upload the webpage page-controls-servo.html to your WX *
''* Visit http://192.168.4.1/files/page-controls-servo.html *
''* I did not make the html, parallax did? *
''**************************************************************
CON
_CLKMODE=XTAL1 + PLL16X ' The system clock spec
_XINFREQ = 5_000_000 ' Crystal
Rx = 31 'serial in from wx device
Tx = 30 'serial out to wx device
ServoPin = 0
OBJ
SERVO : "Servo32v7.spin"
ser: "Parallax Serial Terminal.spin"
VAR
byte Angle, Handle, ReplyStatus
long Stack1[100]
Pub Main
cognew(Comms, @Stack1)
Pub Comms | CommandMode, ServoPwm, ServoPwm1, ServoPwm2
ServoPwm := 0
ReplyStatus := 0
dira[TX]~~ ' Set direction to output
outa[TX]:= 0 ' Set TX low.
waitcnt(10_000_000 + cnt) 'wait 1/10 second for command mode to start in the module.
dira[TX]~ ' Set direction to input
ser.StartRxTx(RX, TX, 0, 115200) 'Cog #2
waitcnt(10_000_000 + cnt) 'wait 1/10 second for serial to start.
SERVO.Start ' Cog 3 Start servo handler
ser.char(254) 'Begin marker
ser.str(string("LISTEN:HTTP,/servo")) 'Tell the module to listen to a specific path on http port 80.
ser.char(13) 'End marker
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[2J")) 'Clear putty telnet screen.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[2;3f")) 'Set Position in putty.
ser.str(string("Prop Started")) 'Tell putty command mode is on.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[1;1f")) 'Set Position in putty to put cursor at 0
Repeat 10 ' wait 10 seconds to help determine if servo reset prop.
waitcnt(80_000_000 + cnt) 'wait 1 second
Repeat 'The main repeat loop.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[2J")) 'Clear putty telnet screen.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[2;3f")) 'Set Position in putty.
ser.str(string("Command Mode is On. ")) 'Tell putty command mode is on.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[1;1f")) 'Set Position in putty to put cursor at 0
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[4;3f")) 'Set Position in putty
If ReplyStatus == 1
ser.str(string("Good reply.")) 'If last reply was good, put it back up on putty which was cleared.
Else
ser.str(string(" No reply.")) 'If last reply was bad, put it back up on putty which was cleared.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[5;3f")) 'Set Position in putty to put cursor at 0
ser.str(string("Angle that the webpage sent: ")) '
ser.dec(Angle)
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[6;3f")) 'Set Position in putty
ser.str(string("Calculate Pwm Output: ")) '
ser.dec(ServoPwm)
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[1;1f")) 'Set Position in putty to put cursor at 0
'
ReplyStatus := 0 'Set the reply to bad so it can recheck for a new reply.
Reply[0] := 0 ' clear data
Reply[1] := 0 ' clear data
Reply[2] := 0 ' clear data
Reply[3] := 0 ' clear data
Reply[4] := 0 ' clear data
Reply[5] := 0 ' clear data
Reply[6] := 0 ' clear data
Reply[7] := 0 ' clear data
Repeat 10
ser.rxflush
ser.char(254) 'Begin marker
ser.str(string("POLL:")) 'Tell the module to listen to a ANY protocol/path.
ser.char(13) 'End marker
waitcnt(10_000_000 + cnt) 'Wait for 1/10 s Let buffer fill.
Reply[0] := ser.rxcheck ' should be 254
Reply[1] := ser.rxcheck ' should be =
Reply[2] := ser.rxcheck ' should be P
Reply[3] := ser.rxcheck ' should be ,
Reply[4] := ser.rxcheck ' should be 5 (this could change) The connection identifier to use for this request
Reply[5] := ser.rxcheck ' should be ,
Reply[6] := ser.rxcheck ' should be 1
Reply[7] := ser.rxcheck ' should be 13
If Reply[0] == 254 And Reply[1] == "=" And Reply[2] == "P" And Reply[7] == 13
ReplyStatus := 1 'Set the reply to good so it can be shown in putty.
Handle := Reply[4] 'Store connection identifier.
Reply[0] := 0 ' clear data
Reply[1] := 0 ' clear data
Reply[2] := 0 ' clear data
Reply[3] := 0 ' clear data
Reply[4] := 0 ' clear data
Reply[5] := 0 ' clear data
Reply[6] := 0 ' clear data
Reply[7] := 0 ' clear data
ser.rxflush
ser.char(254) 'Begin marker
ser.str(string("ARG:")) 'Retrieve HTTP GET/POST’s name argument (in query or body) on connection handle.
ser.char(Handle) 'An active connection handle; returned by POLL
ser.str(string(",")) 'Required for a reply
ser.str(string("angle")) 'The argument name to retrieve.
ser.char(13) 'End marker
waitcnt(10_000_000 + cnt) 'Wait for 1/10 s Let buffer fill.
Reply[0] := ser.rxcheck ' should be 254
Reply[1] := ser.rxcheck ' should be =
Reply[2] := ser.rxcheck ' should be S
Reply[3] := ser.rxcheck ' should be ,
Reply[4] := ser.rxcheck ' should be argument value (this could change) -1 no reply
Reply[5] := ser.rxcheck ' should be argument value (this could change) -1 no reply. This could also be 13
Reply[6] := ser.rxcheck ' should be argument value (this could change) -1 no reply. This could also be 13
Reply[7] := ser.rxcheck ' should be 13
If Reply[0] == 254 And Reply[1] == "=" And Reply[2] == "S"
If Reply[5] == 13 'The end marker
Reply[5] := 0 'Zero terminate the string so it can be converted to decimal.
Elseif Reply[6] == 13 'The end marker
Reply[6] := 0 'Zero terminate the string so it can be converted to decimal.
Else 'The end marker all other conditions the end marker is a byte 7
Reply[7] := 0 'Zero terminate the string so it can be converted to decimal.
Angle := ser.StrToBase(@word[@Reply[4]], 10) ' store and convert string angle in byte variable angle.
ServoPwm1 := Angle + 30 'convert angle to pwm
ServoPwm2 := ServoPwm1 / 2 'convert angle to pwm
ServoPwm := 12 * ServoPwm1 + ServoPwm2 'convert angle to pwm
SERVO.Set(ServoPin, ServoPwm) 'Set angle of servo.
'BEWARE your PROP will restart if you change the servo pwm too fast.
'Tie the servo ground close to the power supply, not near the prop.
'Like as if the prop ground is on a different branch than the servo.
ser.char(254) 'Begin marker
ser.str(string("REPLY:")) 'Tell the module to send a reply to the poll response.
ser.char(Handle) 'Should be a number. An active connection handle; returned by POLL.
ser.str(string(",")) 'Required for a reply
ser.str(string("200")) 'The desired HTTP response code for the reply.
ser.str(string(",")) 'Required for a reply
ser.str(string("2")) 'Tell the module how many bytes? (or is this digits?) the reply is.
ser.char(13) 'End marker
ser.str(string("OK")) 'Send OK to the webpage.
'ser.char(13) 'End marker This marker isn't need, I was testing to see if some code was putting the module into command mode again, but it was the servo resetting the prop.
'waitcnt(80_000_000 + cnt) 'Wait for 1 s
DAT
Reply byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
{{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TERMS OF USE: MIT License
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
// Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}}
Here is a working val-from-micro.spin to go with val-from-micro.html... SPIN.
It includes the .side file to use with SimpleIDE.
You can speed it up by getting rid of many of the 1 second pauses, but be careful, you need to give the FullDuplexSerial.spin time to stop and start. If you stop it too fast, the data you sent will not send everything, and if you start it and don't wait long enough, you may lockup the prop.
The file that has everything for this demo is attached below.
It uses PST
''*******************************************************
''* Putty Telnet Wireless WX Val-From-Micro Demo *
''* Author: Clock Loop @ parallax forums *
''* Upload the webpage val-from-micro.html to your WX *
''* Visit http://192.168.4.1/files/val-from-micro.html *
''* I did not make the html, parallax did? *
''*******************************************************
CON
_CLKMODE=XTAL1 + PLL16X ' The system clock spec
_XINFREQ = 5_000_000 ' Crystal
Rx = 31 'serial in from wx device
Tx = 30 'serial out to wx device
OBJ
ser: "Parallax Serial Terminal.spin"
VAR
byte LoopCounter
long Stack1[100]
Pub Main
cognew(Comms, @Stack1)
Pub Comms | CommandMode, Reply1, Reply2, Reply3, Reply4, Reply5, Reply6, Reply7, ReplyStatus
ser.StartRxTx(RX, TX, 0, 115200) 'Cog #2
waitcnt(80_000_000 + cnt) 'wait 1 second for serial to start.
Repeat 'The main repeat loop.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[2J")) 'Clear putty telnet screen.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[4;3f")) 'Set Position in putty
If ReplyStatus == 1
ser.str(string("Good reply.")) 'If last reply was good, put it back up on putty which was cleared.
Else
ser.str(string(" Bad reply.")) 'If last reply was bad, put it back up on putty which was cleared.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[5;3f")) 'Set Position in putty to put cursor at 0
ser.str(string("Loop count number that should be shown on webpage: ")) '
ser.dec(LoopCounter)
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[1;1f")) 'Set Position in putty to put cursor at 0
If CommandMode == 1 'Check for command mode on in spin.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[2;3f")) 'Set Position in putty.
ser.str(string("Command Mode is On. ")) 'Tell putty command mode is on.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[1;1f")) 'Set Position in putty to put cursor at 0
waitcnt(80_000_000 + cnt) 'wait 1 second for serial to stop.
ser.Stop 'Turn off serial to send break.
dira[TX]~~ ' Set direction to output
outa[TX]:= 0 ' Set TX low.
waitcnt(80_000_000 + cnt) 'wait 1 second for command mode to start in the module.
dira[TX]~ ' Set direction to input
ser.StartRxTx(RX, TX, 0, 115200) 'Cog #2
waitcnt(80_000_000 + cnt) 'wait 1 second for serial to start.
ser.char(254) 'Begin marker
ser.str(string("LISTEN:HTTP,/tpfm")) 'Tell the module to listen to a specific path on http port 80.
ser.char(13) 'End marker
waitcnt(80_000_000 + cnt) 'wait 1 second
ReplyStatus := 0 'Set the reply to bad so it can recheck for a new reply.
Repeat 10
ser.rxflush
ser.char(254) 'Begin marker
ser.str(string("POLL:")) 'Tell the module to listen to a ANY protocol/path.
ser.char(13) 'End marker
waitcnt(80_000_000 + cnt) 'Wait for 1 s for rx buffer to fill.
Reply1 := ser.rxcheck ' should be 254
Reply2 := ser.rxcheck ' should be =
Reply3 := ser.rxcheck ' should be G
Reply4 := ser.rxcheck ' should be ,
Reply5 := ser.rxcheck ' should be 5 (this could change)
Reply6 := ser.rxcheck ' should be ,
Reply7 := ser.rxcheck ' should be 1
waitcnt(80_000_000 + cnt) 'Wait for 1 s
'
If Reply1 == 254 And Reply2 == "=" And Reply3 == "G"
ReplyStatus := 1 'Set the reply to good so it can be shown in putty.
ser.char(254) 'Begin marker
ser.str(string("REPLY:")) 'Tell the module to send a reply to the poll response.
ser.char(Reply5) 'Should be a number. An active connection handle; returned by POLL.
ser.str(string(",")) 'Required for a reply
ser.str(string("200")) 'The desired HTTP response code for the reply.
ser.str(string(",")) 'Required for a reply
If LoopCounter < 10
ser.str(string("1")) 'Tell the module how many bytes? (or is this digits?) the reply is.
Elseif LoopCounter > 9 AND LoopCounter < 100
ser.str(string("2")) 'Tell the module how many bytes? (or is this digits?) the reply is.
Else
ser.str(string("3")) 'Tell the module how many bytes? (or is this digits?) the reply is.
ser.char(13) 'End marker
ser.dec(LoopCounter) 'Send 1 byte (which is up to 3 characters (in decimal) (254) of data to the module which then sends it to the webpage.
waitcnt(80_000_000 + cnt) 'Wait for 1 s
ser.char(254) 'Begin marker
ser.str(string("SET:cmd-enable,0")) 'Turn command mode off in the WX module.
ser.char(13) 'End marker
CommandMode := 0 'Turn command mode off in spin.
'
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[2;3f")) 'Set Position in putty.
ser.str(string("Command Mode is Off.")) 'Tell putty command mode is off.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[4;3f")) 'Set Position in putty to put cursor at 0
If ReplyStatus == 1
ser.str(string("Good reply."))
Else
ser.str(string(" Bad reply."))
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[5;3f")) 'Set Position in putty
ser.str(string("Loop count number that should be shown on webpage: ")) '
ser.dec(LoopCounter)
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[1;1f")) 'Set Position in putty to put cursor at 0
Repeat 5
waitcnt(80_000_000 + cnt) 'Wait for 1 s
CommandMode := 1 'Turn command mode on in spin.
LoopCounter++
If LoopCounter > 254 'Deal with rollover.
LoopCounter := 0
{{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TERMS OF USE: MIT License
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
// Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}}
Here is a demo to see the output from a Memsic2125 connected to a propeller connected to a WX module.
The webpage updates every 3 seconds.
{{
Spin code by Clock Loop.
The code communicates with the wx module and a propeller that is connected to a Memsic2125
The index.html accelerometer output displays the updated values every 3 seconds.
As usual upload the index html to your wx module: Visit http://192.168.4.1/files/index.html
}}
CON
_CLKMODE = XTAL1 + PLL16X ' The system clock spec
_XINFREQ = 5_000_000 ' Crystal
Rx = 31 'serial in from wx device
Tx = 30 'serial out to wx device
AccXin = 3 'X-axis PWM input. Each axis has a 100 Hz PWM duty cycle output in which acceleration is proportional to the ratio tHx/Tx.
AccYin = 27 'Y-axis PWM input. Each axis has a 100 Hz PWM duty cycle output in which acceleration is proportional to the ratio tHx/Tx.
'AccTemp = 20 'Not used in this demo
'Temperature (Analog Voltage) This pin is the buffered output of the temperature sensor.
'The analog voltage at TOUT is an indication of the die temperature.
'This voltage is useful as a differential measurement of temperature from ambient
' and not as an absolute measurement of temperature.
OBJ
ser: "Parallax Serial Terminal.spin"
MM2125: "Memsic2125"
VAR
byte Handle, ReplyStatus, XTiltListener, YTiltListener
long Comm[100]
Pub Main 'Cog #1
cognew(Comms, @Comm) 'Cog #2 and #3
waitcnt(80_000_000 + cnt) 'Wait for 1 s
Accelerometer 'Start accelerometer loop. Cog #1 and #4
PUB Accelerometer | x, y 'Cog #1 and #4
MM2125.start(AccXin, AccYin) ' Initialize Memsic 2125 Cog #4
waitcnt(80_000_000 + cnt) 'Wait for 1s.
repeat 'Cog #1 loop
x := MM2125.Mx ' Read X axis
y := MM2125.My ' Read Y axis
long[@TiltX][0] := x / 100
long[@TiltY][0] := y / 100
WaitCnt(ClkFreq / 2 + Cnt) 'wait
Pub Comms 'Cog #2 and #3
dira[TX]~~ ' Set direction to output
outa[TX]:= 0 ' Set TX low.
waitcnt(1_000_000 + cnt) 'wait 1/10 second for command mode to start in the module.
dira[TX]~ ' Set direction to input
ser.StartRxTx(RX, TX, 0, 115200) 'Cog #3 Parallax Serial Terminal does NOT work at receiving data 230400 for some reason.
waitcnt(1_000_000 + cnt) 'wait 1/10 second for serial to start.
'
ser.rxflush
ser.char(254) 'Begin marker
ser.str(string("LISTEN:HTTP,/TiltX")) 'Tell the module to listen to a specific path on http port 80.
ser.char(13) 'End marker
waitcnt(1_000_000 + cnt) 'Wait for 1/10 s Let buffer fill.
Reply[0] := ser.rxcheck ' should be 254
Reply[1] := ser.rxcheck ' should be =
Reply[2] := ser.rxcheck ' should be S
Reply[3] := ser.rxcheck ' should be ,
Reply[4] := ser.rxcheck ' should be 1 Use this returned listener id with PATH or CLOSE commands.
' There are a maximum of four listeners available.
' Issuing additional LISTEN commands when all four listeners are already established,
' will result in a response of b = E,4 E (NO_FREE_LISTENER) until a CLOSE command is used to free a listener.
Reply[5] := ser.rxcheck ' should be 13
If Reply[0] == 254 And Reply[1] == "=" And Reply[2] == "S" And Reply[3] == "," And Reply[4] == "1" And Reply[5] == 13
XTiltListener := Reply[4]
Else
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[2;3f")) 'Set Position in putty.
ser.str(string("ERROR, wrong X tilt listener returned.")) 'Tell putty error.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[1;1f")) 'Set Position in putty to put cursor at 0
Repeat
waitcnt(80_000_000 + cnt) 'Wait for 1s forever.
Reply[0] := 0 ' clear data
Reply[1] := 0 ' clear data
Reply[2] := 0 ' clear data
Reply[3] := 0 ' clear data
Reply[4] := 0 ' clear data
Reply[5] := 0 ' clear data
ser.rxflush
ser.char(254) 'Begin marker
ser.str(string("LISTEN:HTTP,/TiltY")) 'Tell the module to listen to a specific path on http port 80.
ser.char(13) 'End marker
waitcnt(1_000_000 + cnt) 'Wait for 1/10 s Let buffer fill.
Reply[0] := ser.rxcheck ' should be 254
Reply[1] := ser.rxcheck ' should be =
Reply[2] := ser.rxcheck ' should be S
Reply[3] := ser.rxcheck ' should be ,
Reply[4] := ser.rxcheck ' should be 1 Use this returned listener id with PATH or CLOSE commands.
' There are a maximum of four listeners available.
' Issuing additional LISTEN commands when all four listeners are already established,
' will result in a response of b = E,4 E (NO_FREE_LISTENER) until a CLOSE command is used to free a listener.
Reply[5] := ser.rxcheck ' should be 13
If Reply[0] == 254 And Reply[1] == "=" And Reply[2] == "S" And Reply[3] == "," And Reply[4] == "2" And Reply[5] == 13
YTiltListener := Reply[4]
Else
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[2;3f")) 'Set Position in putty.
ser.str(string("ERROR, wrong Y tilt listener returned.")) 'Tell putty error.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[1;1f")) 'Set Position in putty to put cursor at 0
Repeat
waitcnt(80_000_000 + cnt) 'Wait for 1s forever.
Reply[0] := 0 ' clear data
Reply[1] := 0 ' clear data
Reply[2] := 0 ' clear data
Reply[3] := 0 ' clear data
Reply[4] := 0 ' clear data
Reply[5] := 0 ' clear data
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[2;3f")) 'Set Position in putty.
ser.str(string("Prop Communication Started")) 'Tell putty command mode is on.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[1;1f")) 'Set Position in putty to put cursor at 0
Repeat 10 ' wait 10 seconds to help determine if prop reset.
waitcnt(80_000_000 + cnt) 'wait 1 second
Repeat 'The main repeat loop. Cog#2
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[2J")) 'Clear putty telnet screen.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[2;3f")) 'Set Position in putty.
ser.str(string("Command Mode is On. ")) 'Tell putty command mode is on.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[1;1f")) 'Set Position in putty to put cursor at 0
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[4;3f")) 'Set Position in putty
If ReplyStatus == 1
ser.str(string("Good reply.")) 'If last reply was good, put it back up on putty which was cleared.
ReplyStatus := 0 '
Else
ser.str(string(" No reply.")) 'If last reply was none, put it back up on putty which was cleared.
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[5;3f")) 'Set Position in putty
ser.str(string("Tilt X that the Prop sent: ")) '
ser.dec(long[@TiltX][0])
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[6;3f")) 'Set Position in putty
ser.str(string("Tilt Y that the Prop sent: ")) '
ser.dec(long[@TiltY][0])
ser.str(string(27)) 'Set ansi command mode in putty.
ser.str(string("[1;1f")) 'Set Position in putty to put cursor at 0
ser.char(13) 'End marker
Reply[0] := 0 ' clear data
Reply[1] := 0 ' clear data
Reply[2] := 0 ' clear data
Reply[3] := 0 ' clear data
Reply[4] := 0 ' clear data
Reply[5] := 0 ' clear data
Reply[6] := 0 ' clear data
Reply[7] := 0 ' clear data
Repeat 400
Reply[0] := 0 ' clear data
Reply[1] := 0 ' clear data
Reply[2] := 0 ' clear data
Reply[3] := 0 ' clear data
Reply[4] := 0 ' clear data
Reply[5] := 0 ' clear data
Reply[6] := 0 ' clear data
Reply[7] := 0 ' clear data
ser.rxflush
ser.char(254) 'Begin marker
ser.str(string("POLL:")) 'Tell the module to listen to a ANY protocol/path.
ser.char(13) 'End marker
waitcnt(2_000_000 + cnt) 'Wait for 1/10 s Let buffer fill.
Reply[0] := ser.rxcheck ' should be 254
Reply[1] := ser.rxcheck ' should be =
Reply[2] := ser.rxcheck ' should be P
Reply[3] := ser.rxcheck ' should be ,
Reply[4] := ser.rxcheck ' should be 5 (this could change) The connection identifier to use for this request
Reply[5] := ser.rxcheck ' should be ,
Reply[6] := ser.rxcheck ' should be 1 or a 2. Use this returned listener id with PATH or CLOSE commands.
' There are a maximum of four listeners available.
' Issuing additional LISTEN commands when all four listeners are already established,
' will result in a response of b = E,4 E (NO_FREE_LISTENER) until a CLOSE command is used to free a listener.
Reply[7] := ser.rxcheck ' should be 13
If Reply[0] == 254 And Reply[1] == "=" And Reply[2] == "G" And Reply[6] == XTiltListener And Reply[7] == 13
ReplyStatus := 1 'Set the reply to good so it can be shown in putty.
Handle := Reply[4] 'Store connection identifier.
Reply[0] := 0 ' clear data
Reply[1] := 0 ' clear data
Reply[2] := 0 ' clear data
Reply[3] := 0 ' clear data
Reply[4] := 0 ' clear data
Reply[5] := 0 ' clear data
Reply[6] := 0 ' clear data
Reply[7] := 0 ' clear data
ser.rxflush
ser.char(254) 'Begin marker
ser.str(string("REPLY:")) 'Retrieve HTTP GET/POST’s name argument (in query or body) on connection handle.
ser.char(Handle) 'An active connection handle; returned by POLL
ser.str(string(",")) 'Required for a reply
ser.str(string("200")) 'The desired HTTP response code for the reply.
ser.str(string(",")) 'Required for a reply
ser.str(string("4")) 'Tell the module how many bytes? (or is this digits?) the reply is.
ser.char(13) 'End marker
ser.dec(long[@TiltX][0]) 'Send 1 byte (which is up to 4 characters (in decimal) (xxxx) of data to the module which then sends it to the webpage. '
If Reply[0] == 254 And Reply[1] == "=" And Reply[2] == "G" And Reply[6] == YTiltListener And Reply[7] == 13
ReplyStatus := 1 'Set the reply to good so it can be shown in putty.
Handle := Reply[4] 'Store connection identifier.
Reply[0] := 0 ' clear data
Reply[1] := 0 ' clear data
Reply[2] := 0 ' clear data
Reply[3] := 0 ' clear data
Reply[4] := 0 ' clear data
Reply[5] := 0 ' clear data
Reply[6] := 0 ' clear data
Reply[7] := 0 ' clear data
ser.rxflush
ser.char(254) 'Begin marker
ser.str(string("REPLY:")) 'Retrieve HTTP GET/POST’s name argument (in query or body) on connection handle.
ser.char(Handle) 'An active connection handle; returned by POLL
ser.str(string(",")) 'Required for a reply
ser.str(string("200")) 'The desired HTTP response code for the reply.
ser.str(string(",")) 'Required for a reply
ser.str(string("4")) 'Tell the module how many bytes? (or is this digits?) the reply is.
ser.char(13) 'End marker
ser.dec(long[@TiltY][0]) 'Send 1 byte (which is up to 4 characters (in decimal) (xxxx) of data to the module which then sends it to the webpage.
DAT
TiltX long 0
TiltY long 0
Entry byte 0
'Byte[#] '0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 18 20
Reply byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
{{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TERMS OF USE: MIT License
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}}
Here is a prop to wx to wx to prop communiction code example.
You need to change caboose.railroad.local to the proper domain name of the target wx for the CONNECT command.
And then you will need to change the address to the same proper domain name, in the send packet,
and count and also change the number of bytes more or less that changed for your target domain name.
Unless you use a domain name that uses the same amount of characters as "caboose.railroad.local"
ser.str(string("GET /hostess HTTP/1.1")) '21 21 Twinkies.
ser.char(13) '\r 1 22
ser.char(10) '\n 1 23
ser.str(string("Host: caboose.railroad.local")) '28 51 Change this to match your hostname.domain.local you will need to count the total bytes with the new address.
ser.char(13) '\r 1 52
ser.char(10) '\n 1 53
ser.str(string("Connection: keep-alive")) '22 75
ser.char(13) '\r 1 76
ser.char(10) '\n 1 77
ser.str(string("Accept: */*")) '11 88
This code is rough and some of the comments are wak or wrong, but the code works.
Let it run for a bit to loop, so it syncs.
Beware some of my code comments are completely wrong, due to me copying code and not changing the comment, sorry.
But the code works and most comments are correct, if you have interest in a specific code example and want me to double check it for bad comments, just ask.
I don't already do it because i doubt anyone uses this stuff?, they use C, and even parallax seems to have gone that direction, with all the great wx examples and tutorials done already in c.
Perhaps these spin examples might help someone, once or twice every so decade. They help me when my hard drive crashes. hehe.
I had issues programming a prop chip when I connected the DI and DO pins directly to the prop pins.
Apparently using a 1k resistor might be a good idea? I can only suspect that the wx module is sucking power from the prop rx/tx pins? Or versa?
I will test to see if that is in fact what I am seeing.
I mean with a resistor between the rx and do.
And also the tx and di.
Many wifi applications are battery, which are subject to power dropouts, in an attempt to reduce this, low dropout regulators are used..
But even then the power drops out or barely, to help in recovery of the devices in those situations,
limiting i/o flow increases the chance of recovery without a device lockup after power restore due to odd current flow through the i/o.
Nope (just like in your pic), many will probably NEVER encounter this, however breadboard prototypers will.
I just tried programming at 921600 baud, and my telnet debug out at that same speed.
Both work. So I guess I could scope the i/o to see if it looks ok, but since it works at the highest speed,
there is likely no harm in adding 1k series to the i/o on the esp power hog monster.
Comments
What version of simpleIDE are you using?
Either my compile is doing something wrong, or there is a bug in one of these...
I would think someone would have noticed this by now..?
So it must be my compile environment? hmm?
https://github.com/parallaxinc/SimpleIDE/blob/qt5side/propside/buildspin.h
https://github.com/parallaxinc/SimpleIDE/blob/qt5side/propside/buildspin.cpp
SimpleIDE 1.0.2 (RC2)
And, an older version worked as well!
SimpleIDE 1.1.0 (That I've modified slightly for other reasons)
You can replace the spin compiler ONLY if it can accept openspin's option list (additional options are OK)!
dgately
hmm.. think i'll steam up a cup a joe...
Perhaps its the newer QT5.11 that broke it?
Or should I have compiled GCCv6 instead of GCCv4?
So many options...
I suppose now I need to parse the build log....
Compiling v 1.1.0 didn't change anything.
This must be a QT5.4 vs QT5.11 problem.
Hmm. ..sinking in c quicksand..
I don't even need the compiler options, actually, but I want to be able to make it proper if I am going to share it.
I don't own a P2, and so I don't have an immediate need for the p2 compiler switch.
But I'd still like to fix it, since i have been wanting to get into the qt ide for a while now, its nice to have a reason to use qt, and now i do.
I will now install the parallax older version and see if it even accepts the switch.
That will get me closer to knowing if its a os or build environment version issue.
SimpleIDE from the parallax site linux v1.0.1 RC1 does this also for me. Hmm could this be linux only?
Well, i can compile a raspberrypi version and try it.
I can make a mac one too, but i can't test it.
When I do add more I don't usually make another post, so the thread will not show up at the top.
So check back if the content interests you, it may improve!
Since it contains so much info, parallax customers might benefit by making it sticky status.
Or if parallax wants to hack this thread up and turn it into an official sticky more to their liking, DO IT.
Just let me keep my copy, so i can change it when things change(like when people change repos that break these instructions)
If anyone wants to copy the info here and use it somewhere else, DO IT.
All this info was made from parsing the interwebz and help/info from forum users!
I may at one point create a windows version, but not now.
PropGCC needs to be updated, and most peeps involved know that, and I suspect it will be updated for the P2.
QT5.11 causes code issues in older code, which needs to also be updated, I don't what the status is on that.
Since I am getting into working in QT, I will keep this thread updated if I learn more things about it or the SimpleIDE code.
I hope this info helps someone!
It helps me all the time when I want to re-do my system, and forget all the steps to get to the ability to compile SimpleIDE.
Lots of steps involved!
To fix:
Change line 193 at: esp-open-sdk/crosstool-NG/configure.ac
like this:
then run make again
It would be better to edit the configure.ac file as suggested, to avoid permission issues, but....
I have attached the fixed file. Change its name to configure.ac (remove the .txt) It goes into esp-open-sdk/crosstool-NG/
If you ever run the make as root, you will need to remove the esp-open-sdk folder completely, and then re GET it, and then change/download the configure.ac file again and overwrite the one in esp-open-sdk/crosstool-NG/ ...don't run as su/sudo.
If any more errors are discovered in this compile process I am doing today, I will edit this post with the fixes.
I will be compiling my own custom esp webpage for my parallax WXesp8266 device.
To use as a wireless model railroad engine controller.
I ran through the first set of compiling, I stopped at the part that starts to prepare code for the compile of, SimpleIDE.
(propGCC and the rest) Since support for SimpleIDE is getting stale, I will not do that part.
You can download precompiled versions of simpleide here: https://parallax.com/downloads/simpleide-software-windows-propeller-c
I will start by linking to the large list of WX wifi PROP C examples.
https://learn.parallax.com/tutorials/language/propeller-c/parallax-wx-wi-fi-module-prop-c
DO NOT GO TO BELOW LINK UNLESS YOU WANT TO BE SUPER CONFUSED, ITS BARELY EVEN ENGLISH.
SORRY SPIN USERS, WE ARE SOL... for now.
Some of the WX wifi Prop C examples have already been converted to WX wifi SPIN examples.
https://github.com/parallaxinc/propeller/tree/master/libraries/community/p1/All/WX ESP8266 SPIN Get Started
I HAVE PROVIDED AN EXAMPLE SPIN for the webpage val-from-micro.html below!
So, because LEDs and BUTTONS are a great way to introduce people to coding.
Web Page Controlled LED Lights
https://learn.parallax.com/tutorials/language/propeller-c/parallax-wx-wi-fi-module-prop-c/web-page-controlled-led-lights
Display Pushbutton States
https://learn.parallax.com/tutorials/language/propeller-c/parallax-wx-wi-fi-module-prop-c/display-pushbutton-states
I have created the SPIN version of some of the C examples lower, keep skrollin'.
Make sure your firewall isn't blocking the port (32420) and FlexGUI or SimpleIDE program.
-FlexGUI
https://github.com/totalspectrum/flexgui/releases/tag/v4.3.1
https://forums.parallax.com/discussion/170730/flexgui-a-complete-programming-system-for-p2-and-p1/p1
-SimpleIDE v1.1.2
https://parallax.com/downloads/simpleide-software-windows-propeller-c
I have used the motor control, and change text examples at:
https://learn.parallax.com/tutorials/language/propeller-c/parallax-wx-wi-fi-module-prop-c
... to create a webpage that allows me to control the speed.
I changed the colors by editing /Parallax-ESP/html/style.css (i changed the backgrounds to black, and added a text style for white text.,
I changed the /Parallax-ESP/html/logo.png to match my locomotive image.
I also changed the /Parallax-ESP/html/favicon.ico to match my loco. favicon.ico MUST be 32 pixel X 32 pixel or 16 X 16.
I am pretty sure the favicon.ico can be .PNG format that was simply renamed to a .ICO file format.
I changed the titles in the /Parallax-ESP/html/index.html page to my locomotives title for the "home" page.
It doesn't show my module information because I am running the html locally, not on the esp yet for testing the html changes.
The spin code that will run on the propeller, will need more time to create, because I will need to covert all the C code in the header files and the main file to spin.
This is why I created this thread, to let users, and myself, be able to change the looks of their WX webpage, even if they forget how to do it all years later, they can come to this thread and do it again.
As I complete the html code, and spin code, I will post the entire example here in this single post.
(I will edit this and add it.)
The first time you access it, you should use http://192.168.4.1 as the address.
If you connect it to your network, then you will need to find its IP address and access it using that address.
Do NOT use https:// it will not work.
I have 3 wifi devices and 2 of them are USB, the usb ones kept dropping my connection to the esp.
My tenda usb wifi device, tendas to suck at wifi, apparently, with the ESP 8266.
Some WIFI devices work great with the ESP8266's, others completely fail at saying connected.
For me, my logo.png was too large. I could also change my file format to GIF to preserve transparency.
I colored my transparency to match my webpage background color, and saved it as a JPG with high compression. (like 50%)
I also had to change the index.html to match it.
Don't forget to change ALL HTML files in all folders when you change things because some files have identical content.
For my logo to work I had to change all logo.png to logo.jpg in;
index.html, log.html, newpage.html, settings.html, update-ffs.html.
I also had to change the
Parallax-ESP/html/flash/index.html, and
Parallax-ESP/html/websocket/index.html, and
Parallax-ESP/html/wifi/wifi.html, and
Parallax-ESP/html/wifi/connecting.html
You can see that the WX device uses multiple locations to store many files, like index.html.
If your webpage changes are not taking, you most likely missed updating the change also
in the main /Parallax-ESP/html/ folder and its subfolders, flash, websocket, and wifi.
(If you can't access the web anymore, if you have TWO wifi devices or have a wired internet)
Set your wifi device IP address that accesses the ESP device to 192.168.4.2, this is only for AP mode.
If you changed the IP of your ESP device and you are still accessing it in AP mode you can try adding 1 to the ip that the esp device uses, and put that as your wifi devices IP.
It is all written in spin.
Plug in a pair of headphones or speakers to hear it.
You will see the WX audio output LEDS light up during the audio.
You can read the output of the text with PUTTY connected to the WX's ip address using port 23. (telnet)
The demo uses Raymond Allens SPIN wav player.
I had to modify it to show text output to putty over the wifi instead of TV
It was also modified to use the proper pins for audio and the sd card, for the Activity Board Wx.
Make sure the format on the sd card is FAT (fat16)
Put the 4 wav files on your micro sd card, and put the card into the Activity Board Wx sd slot.
The .wav file format is: PCM 16.000kHz 16bits mono.
Connect to the WX board using wifi, upload the program using SimpleIDE or FlexGUI.
(FlexGUI will automatically load a terminal to view the telnet output when you upload the program to the propeller)
You will hear the BORG queen from start trek next generation.
You can hear the other wave files by removing the ' symbol shown below in front of the one you want to hear
Make sure to put a ' in front of the one that doesn't have one when you change it.
Start putty and connect to your WX esp IP using telnet port 23, in putty, before you upload the program.
The zip file contains all the files needed.
It also contains the .side file for SimpleIDE
The wx settings are also shown.
The Activity Board WX needs to have DTR (gpio12) RESET pin set to program the propeller, on the settings web page. (see image)
I also tie the SEL pin high (3.3v) with a 1k resistor to force the use of the WIFI interface. (sometimes the USB will be activated, even when I don't have usb connected)
its using a different repo for 'esp-open-sdk' and I don't know yet or may never know how to fix the compile process.
So I changed the instructions to use the previously working head, i will post changes if the new change is fixed / or compile instructions are discovered.
It has not been pushed into the Parallax-Esp github repo yet.
You can read about the changes here: http://forums.parallax.com/discussion/171311/parallax-esp-module-latest-hack/p1
Here is the windows Flash-all.bat script.
How to connect a PROPPLUG to the ESP. Purchase a PropPlug to flash an ESP8266 --> https://www.parallax.com/product/32201
And purchase a Parallax WX ESP8266 WiFi Module - SIP --> https://www.parallax.com/product/32420s
SUPPORT PARALLAX, DON'T BE A LEECH! (lol)
PGM (IO0) must be tied to GROUND BEFORE POWER ON.
This version nuumber is of my own creation so the latest compile doesn't conflict with 1.2
(the version on the HOMEPAGE of the module will show 1.9b1, if its above that, it will not work with proploader.)
You can read about the features and on going development here:
https://forums.parallax.com/discussion/171311/parallax-esp-module-latest-hack/p1
This has all the updates to the firmware since the first release 1.0 and the release 1.2
New functions:
1) Can hide and unhide the WiFi module from the programmer without rebooting module.
2) Can set IP address, Gateway, Mask and DNS server.
3) Can send and receive UDP packets.
See the release-notes.txt file for all the updates included in this firmware.
Ok heres a zip with all the files needed for linux users or windows users to flash an esp to PARALLAX.
It also contains the OTA file for over the air updates (only for modules with 2MB or more of flash.)
Linux users, run ./flash-all.sh
Windows users, run Flash-all.bat
MY OWN TESTING HAS FOUND THIS:
If you like parallax's ESP open source code, and the ability to download programs via WIFI to your mcu, SUPPORT PARALLAX.
Purchase a PropPlug to flash an ESP8266 --> https://www.parallax.com/product/32201
And purchase a Parallax WX ESP8266 WiFi Module - SIP --> https://www.parallax.com/product/32420s
SUPPORT PARALLAX, DON'T BE A LEECH! (lol)
To use an OFFICIAL very old v1.0 version see 2 posts down.
I RECOMMENDED USING THIS VERSION. (v1.9b1 is not fully tested)
It is all the updates since, and including OFFICIAL v1.0, up to OFFICIAL v1.9b1.
It contains MANY features like: Updating the DNS with the HOSTNAME of the module, support for the BADGE, and the ability to choose the PIN NUMBER of the RESET LINE, and also the ability to enable/disable the DEBUG PIN, plus many more things, LOADER BAUD RATE...etc... to name a few, many more, see the release-notes.txt file for all the updates included in this firmware.
A zip with all the files needed for linux users or windows users to flash an esp to PARALLAX.
It also contains the OTA file for over the air updates (only for modules with 2MB or more of flash.)
Linux users, run ./flash-all.sh
Windows users, run Flash-all.bat
If you like parallax's ESP open source code, and the ability to download programs via WIFI to your mcu, SUPPORT PARALLAX.
Purchase a PropPlug to flash an ESP8266 --> https://www.parallax.com/product/32201
And purchase a Parallax WX ESP8266 WiFi Module - SIP --> https://www.parallax.com/product/32420s
SUPPORT PARALLAX, DON'T BE A LEECH! (lol)
Parallax has the 2016 OTA and other files available to downgrade it on their product download pages.
I posted this copy here because it contains the files: esptool-ck (esptool.exe and linux esptool) needed to run the flash-all.sh and flash-all.bat. The official download does not include the esptool-ck file.
https://www.parallax.com/downloads/parallax-wx-wi-fi-module-firmware-and-example-files
That page's download contains all the files to use so you can also program the original files if you want to revert back to parallax's 2016 release.
Just replace the files with that 2016 release and flash.
For windows users to downgrade, the original files need to be renamed to the new names in the new zip so the BAT file can find them.
If you need help, ask here.
OR you can download the attached file, I did it all for you.
I have uploaded a zip file that contains the 2016 files to downgrade your esp.
It works just like the one above, except with the 2016 files, and the correct batch file names.
I also included esptool for both linux and windows, and corrected the linux scripts so they execute the esptool with a "./esptool".
I did not touch the original 2016 esp files.
I included this so windows users could also program an esp, (the original parallax download didn't have a way for windows users to do this.)
If you like parallax's ESP open source code, and the ability to download programs via WIFI to your mcu, SUPPORT PARALLAX.
Purchase a PropPlug to flash an ESP8266 --> https://www.parallax.com/product/32201
And purchase a Parallax WX ESP8266 WiFi Module - SIP --> https://www.parallax.com/product/32420s
SUPPORT PARALLAX, DON'T BE A LEECH! (lol)
What this means is they DO NOT PROVIDE internet and other advanced services that a typical router will provide.
In windows you will get this "error" saying the "connection was unsuccessful," in AP mode, or AP/STA mode.
Notice how it says the connection was unsuccessful, but then it contradicts its self and says it has limited connectivity.
Well, which is it Microsoft? Don't even get me started on that company and the creator of it.
I've been dealing with that garbage since DOS3.11
Don't believe a word of it, just connect to your module at Http://192.168.4.1
(yes you can click this link if your module is currently connected, and it will show the parallax module config page.
...
Heres the "Motor control with sliders", IN SPIN. YEAH BOI.
https://learn.parallax.com/tutorials/language/propeller-c/parallax-wx-wi-fi-module-prop-c/motor-control-sliders
Its done with Parallax Serial Terminal.
Don't make fun of my coding.
BEWARE your PROP will restart if you change the servo pwm too fast.
Tie the servo ground close to the power supply, not near the prop.
Like as if the prop ground is on a different branch than the servo.
That worked for me.
This loop runs really fast, so if you have good wiring to your servo and your prop doesn't reset, you CAN change the pwm pretty fast.
https://learn.parallax.com/tutorials/language/propeller-c/parallax-wx-wi-fi-module-prop-c/page-requests-info-propeller
Here is a working val-from-micro.spin to go with val-from-micro.html... SPIN.
It includes the .side file to use with SimpleIDE.
You can speed it up by getting rid of many of the 1 second pauses, but be careful, you need to give the FullDuplexSerial.spin time to stop and start. If you stop it too fast, the data you sent will not send everything, and if you start it and don't wait long enough, you may lockup the prop.
The file that has everything for this demo is attached below.
It uses PST
The webpage updates every 3 seconds.
You need to change caboose.railroad.local to the proper domain name of the target wx for the CONNECT command.
And then you will need to change the address to the same proper domain name, in the send packet,
and count and also change the number of bytes more or less that changed for your target domain name.
Unless you use a domain name that uses the same amount of characters as "caboose.railroad.local"
That portion of the code looks like this and is called a "HTTP session client request."
You can read about it here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Session This code is rough and some of the comments are wak or wrong, but the code works.
Let it run for a bit to loop, so it syncs.
Beware some of my code comments are completely wrong, due to me copying code and not changing the comment, sorry.
But the code works and most comments are correct, if you have interest in a specific code example and want me to double check it for bad comments, just ask.
I don't already do it because i doubt anyone uses this stuff?, they use C, and even parallax seems to have gone that direction, with all the great wx examples and tutorials done already in c.
Perhaps these spin examples might help someone, once or twice every so decade. They help me when my hard drive crashes. hehe.
Just a note about the parallax WX module.
I had issues programming a prop chip when I connected the DI and DO pins directly to the prop pins.
Apparently using a 1k resistor might be a good idea? I can only suspect that the wx module is sucking power from the prop rx/tx pins? Or versa?
I will test to see if that is in fact what I am seeing.
You me like this:
I have all my units connected this way, work great, even on the P2.
Mike
I mean with a resistor between the rx and do.
And also the tx and di.
Many wifi applications are battery, which are subject to power dropouts, in an attempt to reduce this, low dropout regulators are used..
But even then the power drops out or barely, to help in recovery of the devices in those situations,
limiting i/o flow increases the chance of recovery without a device lockup after power restore due to odd current flow through the i/o.
Nope (just like in your pic), many will probably NEVER encounter this, however breadboard prototypers will.
I just tried programming at 921600 baud, and my telnet debug out at that same speed.
Both work. So I guess I could scope the i/o to see if it looks ok, but since it works at the highest speed,
there is likely no harm in adding 1k series to the i/o on the esp power hog monster.