Post topics, source code that relate to the Arduino Platform

User avatar
By sistemasorp
#2161 Well, after a bit of work I have finished the Arduino remote programmer. First the video:



Then the Arduino sketch: http://pastebin.com/vfQu9Mr8

And finally the python server: http://pastebin.com/hjwNndRL

As you can see the Arduino sketch connects to the computer using port 49000 (the test server is SocketTest). Then it sends the hello world! string indefinitely until the sketch receives the reboot command, in which case the sketch connects to the computer using port 50000 in data mode. After that, the sketch sends the hello string and waits for a welcome string sended by the Python server. The next step is to send the .hex file that is wanted to be "served" and wait an ok from Python server. When it is received the last step is to reboot Arduino... How is it done?, well, when Arduino reboots, every pin is configured as INPUT, so you can connect pin 12 and reset pin directly, when you want to reset Arduino you have to configure pin 12 as OUTPUT and set it to LOW to perfom a reset like you press the reset button.

Image
hosting imagenes

The Python server is waiting a 0 byte (the one that Arduino sends when enter in bootloader) to begin the stk500 protocol (You can find a good explanation about the protocol in Arduino here: http://baldwisdom.com/bootloading/ The official document is here: http://www.atmel.com/Images/doc2525.pdf ). If everything is success the Arduino board will have the required hex file programmed into its FLASH memory. The python server closes the TCP connection for two reasons:
1-To force ESP8266 to leave data mode (You can exit sending +++ as I posted in other thread, but if the connection is closed then it leaves data mode too)
2-To listen to other sketches querying other .hex files.

Finally in the video you can watch how the Arduino connects again to the server with port 49000 and send hello world! as is programmed in the sketch.

Oh, I forgot to say the ESP8266 firmware version is 00180902. I had troubles with previous versions.
User avatar
By alonewolfx2
#2666 Its cool :) are you planning to add security check ?
sistemasorp wrote:Well, after a bit of work I have finished the Arduino remote programmer. First the video:

http://youtu.be/gvtqL34iNkU

Then the Arduino sketch: http://pastebin.com/vfQu9Mr8

And finally the python server: http://pastebin.com/hjwNndRL

As you can see the Arduino sketch connects to the computer using port 49000 (the test server is SocketTest). Then it sends the hello world! string indefinitely until the sketch receives the reboot command, in which case the sketch connects to the computer using port 50000 in data mode. After that, the sketch sends the hello string and waits for a welcome string sended by the Python server. The next step is to send the .hex file that is wanted to be "served" and wait an ok from Python server. When it is received the last step is to reboot Arduino... How is it done?, well, when Arduino reboots, every pin is configured as INPUT, so you can connect pin 12 and reset pin directly, when you want to reset Arduino you have to configure pin 12 as OUTPUT and set it to LOW to perfom a reset like you press the reset button.

Image
hosting imagenes

The Python server is waiting a 0 byte (the one that Arduino sends when enter in bootloader) to begin the stk500 protocol (You can find a good explanation about the protocol in Arduino here: http://baldwisdom.com/bootloading/ The official document is here: http://www.atmel.com/Images/doc2525.pdf ). If everything is success the Arduino board will have the required hex file programmed into its FLASH memory. The python server closes the TCP connection for two reasons:
1-To force ESP8266 to leave data mode (You can exit sending +++ as I posted in other thread, but if the connection is closed then it leaves data mode too)
2-To listen to other sketches querying other .hex files.

Finally in the video you can watch how the Arduino connects again to the server with port 49000 and send hello world! as is programmed in the sketch.

Oh, I forgot to say the ESP8266 firmware version is 00180902. I had troubles with previous versions.
User avatar
By alonewolfx2
#2679
sistemasorp wrote:
alonewolfx2 wrote:Its cool :) are you planning to add security check ?


emm... about if the code was loaded correctly or using secure sockets?

about secure socket or secure connection. this can be perfect with security upload. actually i dont want to can anyone upload hex my garage lock :)