Openwrt Serial Port Programming In Visual Basic

Openwrt Serial Port Programming In Visual Basic Rating: 7,6/10 3038votes
Openwrt Serial Port Programming In Visual BasicOpenwrt Serial Port Programming In Visual Basic

Disclaimer: None of the opinions expressed on these pages are paid for. They are strictly my own and may not represent an endorsement of someone's project, product or service (unless otherwise stated so).

Index •, the current update • • • • •, links about hardware •, Open Source and otherwise •, links that just don't fit elsewhere •, links to commercial products for Linux and HA hardware. • - Links to things that may only exist for a short period of time, like newpaper articles. • • old updates are moved here. • - Where dead links go to rest. •, BLOGS dedicated towards HA. •, my miscellaneous ramblings. Update: 2013 2014/01/04 - Javier Pardo Blasco sent in his HA project.

Warning: Invalid argument supplied for foreach() in /srv/users/serverpilot/apps/jujaitaly/public/index.php on line 447. All code that manipulates the serial port should appear within this block or within a Try.Catch.Finally block. The WriteLine method sends the data to the serial port. Sub SendSerialData(ByVal data As String) ' Send strings to a serial port. Using com1 As IO.Ports. Lounge Lizard Mac Crack Software on this page. SerialPort = My.Computer.

He's been working in a home automation project, coded in Python called He says it's modular, it's web based, it publishes a REST API, 2013/11/12 - I've been a bit busy with work and learnign the wonderful world of TDD. I have a few books on C, Python and Javascript.

At the moment they do a nice job of explaining but a lousy job of showing a few simple startup examples (but I'm not done reading). Sergei Jeihala was kind enough to share his project with us. It is: • Web-based • Easy to configure / install • Cross-platform (Linux/Windows) • Multiple protocols support (Z-Wave, 1-wire, SNMP, ethernet-devices, etc.) • PHP-based scripting (with visual scripting using Google Blockly) I'm still working on the ECM-1240, I've run out of serial ports and I'm working on getting a terminal server working. 2013/09/19 - I've been quiet for a while but I'm hoping (keeping my fingers crossed on that) that is now behind me. I've just picked up a ECM-1240. I still have to install it. I'll be using Pi as the terminal/web (node.js) server to it.

This will allow me to monitor my home's power usage. While searching for some more information I found this blog called. I think it's cool so I'll add it to my page (which really needs to be cleaned up). I've restarted writting software and I'll start adding it here and to my web site. I'm also working on an irrigation controller called. I've got bits and pieces of it up. Hope to have more soon.

2013/02/21 - - Pytomation is an extensible open source automation system written in Python. It's uses include home automation and lighting control but is certainly not limited to those functions. 2013/02/07 - - This is My effort to get Misterhouse back on the map. The Misterhouse project is not dead. The main Sourceforge page is back under the community's control (Yea!). The most useful code can be picked up from the git repository (explanation on the WIki pages) The - where the old updates are moved to. My interests: Inline with the economy's present cost cutting measures (and my effort to reduce the size of this;-) I'm moved the interests section of my HA page to it's own page oddly called my.

In this location instead you will find a summary of my and of course a link to the longer page. My interests, like any geek, are in gadgets. Almost anything having to do with home automation, control, computers (hardware & software) and electronics. Unlike most geeks I also love to ride my bicycle, not a short tootle 'round the block but prefer longer rides.

Such as 30 mile lunch times rides, 20 mile commutes to work (each way) and a weekend ride of a 100 miles. Also, my bicycles are in no way hooked up to my computers other than a standard bike computer. I prefer it that way. It's my time away from computers. My, in it's full glory.:-).

This shows a proof-of-concept connection of a picaxe to the inter-/local net using an Asus WL-520gU router running the Linux openWrt operating system. The connection is made with a USB serial dongle plugged into the router.

The router’s serial port could be used but it is not brought out of the box. Power (either 5 volt or 3.3 volt) could also be brought out of the router, but for this example 3-AAs are used to power the picaxe. I chose the WL-520gU because it is an inexpensive router ($44US at Newegg, but with discounts and rebates often bringing it down to $30US), and it is easy to flash with openWrt, and hard to brick. The WL-520gU has a 240mHz MIPS processor, 4 megabytes of flash, 16 megabytes of ram, and a USB port. This router is definitely on the laggard end of the router selection nowadays, but it is very easy to use. I actually have brought both power and 3.3-volt serial out of the router, but this project doesn’t use them. The hardware: WL-520gU router, USB-RS232 dongle, RadioShack solderboard (276-150), DB9 connector, PICAXE08M.

The USB-RS232 dongle is from ebay, here: The dongle was $2.38US including shipping, and is a PL2303 serial adaptor (same as my Rev-Ed USB-serial cable--and yes, it does work on my Vista laptop for programming a picaxe). OpenWrt supports this adaptor—many others work, but some may not. I used the RadioShack board for the circuit because it’s easy to wire for the picaxe, and provides good breadboarding space. The schematic for the picaxe is attached below—it includes download connector and DB9 serial to pins 3 and 4. I soldered the DB9 female connector directly to the solderboard, and used the same resistor setup that the standard download circuit uses. The 20-pin socket on the board allows the use of an 08M, 14M, 18M2 (drool), 20M, or 20X2. The picaxe part is pretty straightforward.

Aside from the serial circuitry on pins 3 and 4, no picaxe inputs or outputs were used except for the LED on pin 0. I look forward to playing with a 20x2. I wrote a very simple program for the 08M which looks for input on pin 3 (a qualifier, “A”, and a 1-byte code), and then uses a select statement to execute code based on the value read.

In this case I chose to let “A” mean “turn on LED”, and “B” to mean “turn off LED”. The command set could be about as elaborate as you liked. Data could be sent back to the router to build a web page, send an email, or communicate across the web. The router is running openWrt (). I built my own image from trunk using the following packages: kmod-usb-core, kmod-usb-serial, kmod-serial-pl2303, picocom (terminal program), ssmtp (email program). One trick is that in the busybox configuration, “stty” must be enabled to allow setting of the serial port parameters.

If you were to download a snapshot, this “stty” command would not be available, but a workaround is available if you install the “empty” package ('empty -f picocom -b 2400 -p n -f n -l -r /dev/ttyUSB0' sets the serial parameters in the absence of stty). If everything is configured properly, when you plug in the USB dongle, openWrt will recognize it and create a name for it, ttyUSB0. This file can be accessed as /dev/ttyUSB0, and the picaxe can be written to with a Linux command line command as simple as “echo AA >/dev/ttyUSB0”. Writing a script to both read and write can be done, but it gets complicated, so I use a different language. My favorite language for programming on the openWrt platform is Lua.

It is a lightweight, fast, interpreted language which comes as a default in openWrt. Lua can be run interactively by typing “lua” and then entering commands, or by creating a file and typing, for instance, “lua test.lua”, or by compiling test.lua and running the compiled program.

I’ve never compiled anything—interpreted speed has been fast enough. Here is a very simple Lua program which opens two different files—one for serial in and the other for serial out—writes a command and then reads back the response.

Code: fileserin = io.open('/dev/ttyUSB0','r') fileserout = io.open('/dev/ttyUSB0','w') fileserout:write('AA') – turn on the LED line = fileserin:read('*l') – read the response (a single line) print(line) – this should print “ACK A” The program could create a web page with a command as simple as os.execute(“echo 'LED is on' >/www/test.html”) Then, for my ip, it could be accessed from a browser with “192.168.1.60/test.html”. An email is only slightly more complicated (after the ssmtp configuration file is set up). Code: os.execute('echo 'From: yourname@yourfromaddress.com ' >/home/user0/message') os.execute('echo 'Subject: wl60 email test ' >>/home/user0/message') os.execute('echo 'LED on ' >>/home/user0/message') os.execute('echo '. ' >>/home/user0/message') os.execute('ssmtp lbenson@somewhere.com.

HOWTO: Set up Asus WL-520gU to allow serial connection between picaxe and the internet. This assumes a Windows PC--Linux users will probably know enough to be able to translate these instructions. Hardware: Asus WL-520gU, a router with wifi, wan port, 4 lan ports, a usb port, 4 megabytes of flash memory, and 16 megabytes of ram. See here for openWrt-related information: Note that other devices will work as well, for instance, Asus wl-500gPv2, Buffalo wzr-hp-g300nh, TP-LINK TL-WR1043, Bifferboard, NSLU2 (but with different flashing instructions except for the wl-500gPv2, which will work with these).

Software: OpenWrt, a linux operation system which is modular and can installed on small routers and NASes; supports usb/serial connections to microprocessors such as the picaxe. It is possible to build your own version of openWrt, tailored to the needs of a small router, but one can also use prebuilt 'snapshots' and then download the packages needed. For some reason the current snapshot flashes but doesn't boot on the wl-520, so I have made a custom flashable file, wl520.trx, and made it available for downloading. Download the openWrt basic software: In a DOS box, cd to your preferred destination folder (for instance, c: dl openwrt) and: wget -O wl520.trx My hosting site only allows downloading of files with certain file types, so I renamed the flash binary as a '.txt' file, which can be retrieved with wget.

The '-O' option renames the downloaded file as a 'trx' file--the type used for flashing an openWrt image file. Flash the router: If you build openWrt on your own, you can set it to have any ip address you like. I have chosen 192.168.1.61.

You can change this after the image is flashed. (If you flash a snapshot, it will have an ip address of 192.168.1.1--a very inconvenient address for many purposes, since this is often the default address of your network's gateway router.) You can flash by plugging the WL-520 into your network. If you have problems, run a wire directly from your PC to a lan (not wan) port on the router. Be sure to set your PC's ip to something in the network range (e.g., 192.168.1.31).

With a paper clip or pen depress the recessed BLACK reset button, plug in power, count one-thousand-one, one-thousand-two, one-thousand-three, one-thousand-four, and release the button. The green power light should be flashing off and on. If it isn't, remove power and repeat, counting faster or slower until it works. Use the windows tftp program in dos to flash the router (note that for tftp, the router will be addressed as 192.168.1.1). Tftp -i 192.168.1.1 PUT wl520.trx On my xp machine this takes 5 seconds and nothing is output until the transfer is finished. Wait 2 minutes while the flashing is completed and then plug the WL-520 into your network router and remove and re-insert the power connecter.

Wait a minute or two for the router to reboot. Modify configuration: A newly flashed openWrt router can only be connected to using the telnet protocol. Once you connect with telnet and change the password, telnet will be disabled and access will be through the secure ssh method.

Any number of programs will handle telnet and ssh access. I use putty, which may be downloaded here: Start putty and set up to connect using the telnet protocol to 192.168.1.61. You should get an openWrt greeting.

Change the password by typing 'passwd' and your new password twice. Make it good--include upper and lower case letters, numbers, and special characters.

While you are in via telnet you might as well modify a configuration file to give the wl-520 a name which suits you, and to set up your time zone. Only the clunky vi editor is available on a machine with 4 megabytes of flash (if there is more, I would install nano). OpenWrt system configuration files are located in the '/etc/config' directory. Enter 'vi /etc/config/system' to modify the system file. (Google 'man vi' to get information about using vi--'i' goes into insert mode, where you can type and use Del and Backspace; ':wq' saves and quits; ':q!'

Quits without saving. Sorry--not my fault.) Change the system name from 'OpenWrt' to something you prefer, like 'wl61'. Change the time zone as needed (samples for North America are 'AST4ADT'--Atlantic Canada; 'EST5EDT'--Eastern time; 'CST6CDT'--Central time; 'MST7MDT'--Mountain time; 'PST8PDT'--Pacific time).

Save and quit. Reboot and your putty session will be closed and telnet will be disabled. To get back in, you re-enter putty with the same ip but this time using the SSH connection. Enter 'root' as login ID and the password you set in telnet. Further configuration--email: I set up the files I want in '/home/user0'.

To create this directory, type 'mkdir /home' and 'mkdir /home/user0'. Change to this directory with 'cd /home/user0'.

Create a lua email program by typing 'vi /home/user0/msg.lua'. You'll get a blank file.

Type 'i' to go into insert mode. Copy the following and insert it by right-clicking. Os.execute('echo 'From: ' >/home/user0/message') os.execute('echo 'Subject: wl60 email test ' >>/home/user0/message') os.execute('echo 'LED on ' >>/home/user0/message') os.execute('echo '. ' >>/home/user0/message') os.execute('ssmtp The doctor is in' >/www/test.html Go to your PC's browser and enter the address, '192.168.1.61/test.html'. You should see your web page.

Boston F1 License Fire And Safety. Access from PC: In addition to access through ssh, the program 'openssh-sftp-server' is activated. This means that you can access the device securely, with the same login ID and password, with an SCP program which allows you to view files on your PC in one pane and files on the device in the other, and to move them back and forth. WINSCP is a good windows program for doing this. Thanks for a great write up. Despite all your good work I still have issues.

The issue is this section, ' One trick is that in the busybox configuration, “stty” must be enabled to allow setting of the serial port parameters. If you were to download a snapshot, this “stty” command would not be available, but a workaround is available if you install the “empty” package ('empty -f picocom -b 2400 -p n -f n -l -r /dev/ttyUSB0' sets the serial parameters in the absence of stty).' I can't install the 'empty' package. I get errors like this, root@OpenWrt:/# opkg install empty Collected errors: * opkg_install_cmd: Cannot install package empty. Root@OpenWrt:/# BTW, I checked and the USB dongle does load correctly.

This method of interfacing to the web is very difficult but also very cheap, the router was less then $30. Thanks for all the hard work. I am not having much luck with the serial communication from the usb-serial adapter. I set up a laptop with a null cable to attach to the output from the adapter. There is data when i send 'echo AA >/dev/ttyUSB0', the trouble is I get gibberish and after trying numerous variations of baud rates and control setting i still can't get AA to come out. Of course, I did test my set up by connecting 2 PC's and the cables and hyperterminal are all good. The dongle has been tested with a pc connection and it too is good.

Not sure what to try next.