- Netduino Forums
- → don664's Content
don664's Content
There have been 77 items by don664 (Search limited from 28-April 23)
#40239 RN-XV WiFly Module driver
Posted by don664 on 26 November 2012 - 05:05 PM in Project Showcase
#40238 Replacing texst in strings
Posted by don664 on 26 November 2012 - 05:03 PM in Netduino Plus 2 (and Netduino Plus 1)
I'm trying to post a date/time via an HTTP request for an application I'm writing. The only problem is that I am getting an error because of the space in the date/time.
string = "&dateTimeStamp=06/01/2011 00:00:28"
I need it to be
string = "&dateTimeStamp=06/01/2011%2000:00:28"
I have created the following:
public static string replace(string str, string unwanted, string replacement) { StringBuilder sb = new StringBuilder(str); sb.Replace(unwanted, replacement); return sb.ToString(); }
but calling it like this does not get rid of the space:
string httpLine = replace(originalLine, " ", "%20");
Is there an escape character I should use for replacing the space?
Thanks,
Donovan
#40220 RN-XV WiFly Module driver
Posted by don664 on 26 November 2012 - 11:38 AM in Project Showcase
#40212 RN-XV WiFly Module driver
Posted by don664 on 26 November 2012 - 05:41 AM in Project Showcase
You can swap the integratedsocket for the wifi socket;
http://netmftoolbox....ailable classes
Hi Stefan,
Thanks... but now I don't know how to set the time as "Synchronize" is not part of SimpleSocket:
'Toolbox.NETMF.NET.SimpleSocket' does not contain a definition for 'Synchronize' and no extension method 'Synchronize' accepting a first argument of type 'Toolbox.NETMF.NET.SimpleSocket' could be found (are you missing a using directive or an assembly reference?)
I've tried looking through the IntelliSense options for TimeClient but can't figure out which to use.
// Initializes the time client SimpleSocket TimeClient = new WiFlySocket("time-a.nist.gov", 123, WifiModule); // Displays the time in three ways: Debug.Print("Amount of seconds since 1 jan. 1900: " + TimeClient.NtpLookup()); //Debug.Print("UTC time: " + TimeClient.UTCDate.ToString()); //Debug.Print("Local time: " + TimeClient.LocalDate.ToString()); // Synchronizes the internal clock TimeClient.Synchronize();
#40165 RN-XV WiFly Module driver
Posted by don664 on 25 November 2012 - 02:49 PM in Project Showcase
Thanks for the link... which reference do I need to add for "IntegratedSocket"?
I keep getting the following error:
The type or namespace name 'IntegratedSocket' could not be found (are you missing a using directive or an assembly reference?)
I'm running a Netduino Plus 2.
#40095 RN-XV WiFly Module driver
Posted by don664 on 24 November 2012 - 04:51 AM in Project Showcase
#40013 RN-XV WiFly Module driver
Posted by don664 on 23 November 2012 - 02:56 PM in Project Showcase
By the way, for those who know that netmftoolbox thingy, I also added an SNTP client today
When was this added and is there an example of it's simple usage to set the dateTime on the Netduino?
Thanks,
Donovan
#40010 Netduino Plus 2 NTP class for Wifi
Posted by don664 on 23 November 2012 - 02:40 PM in General Discussion
#40007 Netduino Plus 2 NTP class for Wifi
Posted by don664 on 23 November 2012 - 02:26 PM in General Discussion
#40003 Netduino Plus 2 NTP class for Wifi
Posted by don664 on 23 November 2012 - 02:16 PM in General Discussion
#40002 Netduino Plus 2 NTP class for Wifi
Posted by don664 on 23 November 2012 - 01:41 PM in General Discussion
#39997 Netduino Plus 2 NTP class for Wifi
Posted by don664 on 23 November 2012 - 12:32 PM in General Discussion
#39889 OnInterrupt problem calling WiFly
Posted by don664 on 21 November 2012 - 03:09 PM in General Discussion
#39883 OnInterrupt problem calling WiFly
Posted by don664 on 21 November 2012 - 02:58 PM in General Discussion
#39879 OnInterrupt problem calling WiFly
Posted by don664 on 21 November 2012 - 02:37 PM in General Discussion
You could also make a main loop, not working with interrupts, like you probably did with an Arduino before.
I think that was how I did it before... with a timer to ensure the wifly was only handling one request at a time.
I am thinking that for this to work I may need to have the interrupt write the "count" to the SD card and then every minute (or whatever) have the wiFly upload that file (maybe XML) to the server and then send an HTTP request for the server to get the data from the file.
Are there any examples for FTP with the wifly?
#39874 OnInterrupt problem calling WiFly
Posted by don664 on 21 November 2012 - 02:25 PM in General Discussion
#39873 OnInterrupt problem calling WiFly
Posted by don664 on 21 November 2012 - 02:24 PM in General Discussion
#39798 OnInterrupt problem calling WiFly
Posted by don664 on 21 November 2012 - 10:21 AM in General Discussion
#39796 Socket.Connect locks up Netduino if no network
Posted by don664 on 21 November 2012 - 09:27 AM in Netduino Plus 2 (and Netduino Plus 1)
I'm having a similar problem where I try and access the wifi module to get the local IP (this just for testing and I actually want to create a socket and send an HTTP request) and it simply stops all threads from running.
Any ideas about why I can't access any network related stuff from within my interrupt event method?
Problem detailed here
Thanks,
Donovan
#39792 OnInterrupt problem calling WiFly
Posted by don664 on 21 November 2012 - 07:54 AM in General Discussion
public static void mySensor_OnInterrupt(uint port, uint state, DateTime time) { Debug.Print(WifiModule.MacAddress);
The problem is that I can't access anything related to the WiFi connection like the Local IP Address or creating a socket to send an HTTP request for posting the counter value.
#39790 OnInterrupt problem calling WiFly
Posted by don664 on 21 November 2012 - 07:26 AM in General Discussion
Ok... so I have now added the on-board LED to the project
public class Program { static WiFlyGSX WifiModule; static OutputPort led;
and here
public static void Main() { WifiModule = new WiFlyGSX(); led = new OutputPort(Pins.ONBOARD_LED, false);
Now when the event handler (the interruption of the photo sensor) is triggered I can interact with the led and turn it on and off:
This added to the method:
public static void mySensor_OnInterrupt(uint port, uint state, DateTime time) { led.Write(state == 0);
So why can I interact with the led but not the WifiModule in the event method?
What am I missing?
Thanks,
Donovan
#39745 OnInterrupt problem calling WiFly
Posted by don664 on 20 November 2012 - 04:42 PM in General Discussion
This project includes a Netduino Plus 2, a photo sensor and a RN-XV WiFly module (with wireless shield).
What I am aiming for is that when the application starts a connection is made to the wifi network; then when the photo sensor is triggered a counter variable is sent to a webpage, as a querystring variable, to add it to a database.
Before I create the HTTP request I thought I would make sure I can access the WiFly "instance" from within the OnInterrupt "function/call" by simply getting the Local IP address again and writing it to the Debug window (apologies again if I'm getting the terminology wrong).
There is no problem populating the string "strLocalIP_1" but as soon as I try populate "strLocalIP_2" the application hangs.
What am I missing?
using System; using System.Net; using System.Net.Sockets; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; using Toolbox.NETMF; using Toolbox.NETMF.NET; using Toolbox.NETMF.Hardware; namespace sandbox { public class Program { // declare counter variable, photoSensor and wifly static uint counter = 0; static InterruptPort mySensor; static WiFlyGSX WifiModule; public static void Main() { // Create sensor instance mySensor = new InterruptPort(Pins.GPIO_PIN_D7, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); mySensor.OnInterrupt += new NativeEventHandler(mySensor_OnInterrupt); // Create WiFly instance WifiModule = new WiFlyGSX(); // Allow some time for WiFly to power up and find network Thread.Sleep(5000); // Join Network WifiModule.EnableDHCP(); WifiModule.JoinNetwork("SSID", 0, WiFlyGSX.AuthMode.MixedWPA1_WPA2, "Password"); // Wait for authentication and joining Thread.Sleep(5000); Debug.Print("WiFi connected"); // Get the Local IP to confirm connection to the wifi network string strLocalIP_1; strLocalIP_1 = WifiModule.LocalIP; Debug.Print(strLocalIP_1); // Indefinitely wait for any sensor interrupts... Thread.Sleep(Timeout.Infinite); } public static void mySensor_OnInterrupt(uint port, uint state, DateTime time) { // get the "interrupt" state to stop counter counting twice if (state == 0) { // Write the count to the debug window Debug.Print("counter: " + counter); // Get the Local IP to confirm connection to the wifi network string strLocalIP_2; strLocalIP_2 = WifiModule.LocalIP; Debug.Print(strLocalIP_2); // increase counter by 1 counter++; } } } }
I'm sure it's a real noob oversight on my part but would appreciate any help.
Thanks,
Donovan
#39730 Serial LCD and Netduino Plus 2
Posted by don664 on 20 November 2012 - 12:21 PM in Netduino Plus 2 (and Netduino Plus 1)
#39689 Communicating with serial 2x16 LCD
Posted by don664 on 20 November 2012 - 08:04 AM in Netduino 2 (and Netduino 1)
Thanks for the response.
I have figured it and posted my solution here:
Serial LCD and Netduino Plus 2
Thanks again to Coyttl for also taking the time to help out.
Cheers,
Donovan
#39688 Serial LCD and Netduino Plus 2
Posted by don664 on 20 November 2012 - 08:02 AM in Netduino Plus 2 (and Netduino Plus 1)
After struggling with this for a day I finally got it working and thought I'd share.
The problem seemed to be with the declaration syntax (sorry if I'm using the wrong terminology here) between .Net Micro Framework 4.1 and 4.2.
For example the class I was trying to use declared the serial port like this:
_lcd = new SerialPort(com, 9600, Parity.None, 8, StopBits.One);
Yet it needs to be like this:
_lcd = new System.IO.Ports.SerialPort(com, 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
Once I sorted that out it all seems to be working just fine now. This syntax was corrected by right clicking on the red underlined text, such as SerialPort, and selecting "Resolve"... IntelliSense does the rest for you
Here's the LCD class (LCD.cs):
using System; using Microsoft.SPOT; namespace slcdHelloWorld { class LCD { private System.IO.Ports.SerialPort _lcd; private byte[] clear = { 0xFE, 0x01 }; private byte[] blinkboxon = { 0xFE, 0x0D }; private byte[] blinkboxoff = { 0xFE, 0x0C }; public LCD(string com) { _lcd = new System.IO.Ports.SerialPort(com, 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One); _lcd.Open(); this.Clear(); this.MoveCur(0); this.Write(blinkboxoff); } public void Clear() { this.Write(clear); this.MoveCur(0); this.Write(blinkboxoff); } public void Write(byte[] B) { _lcd.Write(b, 0, b.Length); } public void MoveCur(int i) { this.Write(blinkboxon); if (i > 15) i += 48; byte locByte = (byte)(128 + i); byte[] moveto = { 0xFE, locByte }; Debug.Print("MoveTo - " + moveto[0].ToString() + " - " + moveto[1].ToString() + " - locByte " + locByte.ToString()); this.Write(moveto); } } }
And here's the Program.cs:
using System; using System.Net; using System.Net.Sockets; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; namespace slcdHelloWorld { public class Program { // initialise the LCD display static LCD mylcd = new LCD("COM2"); public static void Main() { // write your code here while (true) { mylcd.Clear(); byte[] bytes = System.Text.Encoding.UTF8.GetBytes("Hello World"); mylcd.Write(bytes); Thread.Sleep(5000); mylcd.Clear(); mylcd.MoveCur(30); } } } }
In terms of connecting up the Serial LCD (https://www.sparkfun.com/products/9395) simply run wires like this (LCD to Netduino):
- RX to Digital I/O pin 3 (which is COM2 TX - netduino Plus Pins Chart)
- GND to GND
- VDD to 5V
Thanks to everyone for the help and hope this saves someone else some time
Cheers,
Donovan
- Netduino Forums
- → don664's Content
- Privacy Policy