I am using netduino plus 2 and barcode scanner (datalogic QD2100) for my project. As netduino plus 2 does not support USB OTG (on the go), I did go with RS232 interface (output of barcode scanner is RS232 female port) option for scanner. I was wondering which break out board (RS232 Shifter SMD) to use for this purpose (please provide URL where to buy-preferably in asia) and also please explain how to connect it to netduino plus 2 as i'm a newbie. Thanks in advance.
- Netduino Forums
- → m.sainath's Content
m.sainath's Content
There have been 7 items by m.sainath (Search limited from 28-April 23)
#47632 netduino plus 2_rs232
Posted by m.sainath on 27 March 2013 - 02:15 PM in Netduino Plus 2 (and Netduino Plus 1)
#48585 implementing serial communication for netduino plus 2
Posted by m.sainath on 21 April 2013 - 12:33 PM in Netduino Plus 2 (and Netduino Plus 1)
using System;using System.Net;using System.Net.Sockets;using System.Threading;using System.IO.Ports;using System.IO.Ports.SerialPort;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;namespace Microsoft.SPOT.Hardware{ public sealed class SerialPort : IDisposable { public SerialPort(SerialPort.Configuration config); public SerialPort.Configuration Config { get; set; } public void Dispose(); public void Flush(); public int Read(byte[] buffer, int offset, int count, int timeout); public int Write(byte[] buffer, int offset, int count); public enum BaudRate { Baud4800 = 4800, Baud9600 = 9600, Baud19200 = 19200, Baud38400 = 38400, Baud57600 = 57600, Baud115200 = 115200, Baud230400 = 230400, } public enum Serial { COM1 = 0, COM2 = 1, COM3 = 2, COM4 = 3, } public class Configuration { public readonly SerialPort.Serial Com; public readonly bool FlowControl; public readonly SerialPort.BaudRate Speed; public Configuration(SerialPort.Serial com, SerialPort.BaudRate speed, bool flowControl); } } }namespace BarcodeScanner{ public class Program { public static void Main() { // write your code here Microsoft.SPOT.Hardware.SerialPort.Configuration config = new Microsoft.SPOT.Hardware.SerialPort.Configuration(Microsoft.SPOT.Hardware.SerialPort.Serial.COM1, Microsoft.SPOT.Hardware.SerialPort.BaudRate.Baud9600, false); Microsoft.SPOT.Hardware.SerialPort serialPort = new Microsoft.SPOT.Hardware.SerialPort(config); byte[] outBuffer = System.Text.Encoding.UTF8.GetBytes("Hello World!rn"); serialPort.Write(outBuffer, 0, outBuffer.Length); serialPort.Dispose(); //keeps the emulator running to see results Thread.Sleep(Timeout.Infinite); } }}
This is the code i'm using to achieve serial communication for a netduino plus 2 based on .NET micro framework. When i do i get a error message stating that "A using namespace directive can only be applied to namespaces; 'System.IO.Ports.SerialPort' is a type not a namespace ". Upon seeing this i comment out the line of code
using System.IO.Ports.SerialPort;
then I encounter couple of error messages stating that "'Microsoft.SPOT.Hardware.SerialPort.Configuration.Configuration(Microsoft.SPOT.Hardware.SerialPort.Serial, Microsoft.SPOT.Hardware.SerialPort.BaudRate, bool)' must declare a body because it is not marked abstract, extern, or partial"
Please help me resolve this issue as soon as possible. The scenario i'm working on is to get data from a barcode scanner via a rs232 cable connected to a breakout board which converts rs232 to serial. Thanks in advance.
#48586 implementing serial communication for netduino plus 2
Posted by m.sainath on 21 April 2013 - 12:34 PM in Visual Studio
using System;using System.Net;using System.Net.Sockets;using System.Threading;using System.IO.Ports;using System.IO.Ports.SerialPort;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;namespace Microsoft.SPOT.Hardware{ public sealed class SerialPort : IDisposable { public SerialPort(SerialPort.Configuration config); public SerialPort.Configuration Config { get; set; } public void Dispose(); public void Flush(); public int Read(byte[] buffer, int offset, int count, int timeout); public int Write(byte[] buffer, int offset, int count); public enum BaudRate { Baud4800 = 4800, Baud9600 = 9600, Baud19200 = 19200, Baud38400 = 38400, Baud57600 = 57600, Baud115200 = 115200, Baud230400 = 230400, } public enum Serial { COM1 = 0, COM2 = 1, COM3 = 2, COM4 = 3, } public class Configuration { public readonly SerialPort.Serial Com; public readonly bool FlowControl; public readonly SerialPort.BaudRate Speed; public Configuration(SerialPort.Serial com, SerialPort.BaudRate speed, bool flowControl); } } }namespace BarcodeScanner{ public class Program { public static void Main() { // write your code here Microsoft.SPOT.Hardware.SerialPort.Configuration config = new Microsoft.SPOT.Hardware.SerialPort.Configuration(Microsoft.SPOT.Hardware.SerialPort.Serial.COM1, Microsoft.SPOT.Hardware.SerialPort.BaudRate.Baud9600, false); Microsoft.SPOT.Hardware.SerialPort serialPort = new Microsoft.SPOT.Hardware.SerialPort(config); byte[] outBuffer = System.Text.Encoding.UTF8.GetBytes("Hello World!rn"); serialPort.Write(outBuffer, 0, outBuffer.Length); serialPort.Dispose(); //keeps the emulator running to see results Thread.Sleep(Timeout.Infinite); } }}
This is the code i'm using to achieve serial communication for a netduino plus 2 based on .NET micro framework. When i do i get a error message stating that "A using namespace directive can only be applied to namespaces; 'System.IO.Ports.SerialPort' is a type not a namespace ". Upon seeing this i comment out the line of code
using System.IO.Ports.SerialPort;
then I encounter couple of error messages stating that "'Microsoft.SPOT.Hardware.SerialPort.Configuration.Configuration(Microsoft.SPOT.Hardware.SerialPort.Serial, Microsoft.SPOT.Hardware.SerialPort.BaudRate, bool)' must declare a body because it is not marked abstract, extern, or partial"
Please help me resolve this issue as soon as possible. The scenario i'm working on is to get data from a barcode scanner via a rs232 cable connected to a breakout board which converts rs232 to serial. Thanks in advance.
#48592 implementing serial communication for netduino plus 2
Posted by m.sainath on 21 April 2013 - 02:18 PM in Netduino Plus 2 (and Netduino Plus 1)
#48622 type conversions for netmf
Posted by m.sainath on 22 April 2013 - 03:37 PM in Visual Studio
using System;using System.Net;using System.Net.Sockets;using System.Threading;using System.IO.Ports;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;namespace barcode_scanner{ public class Program { public static void Main() { InputPort bs = new InputPort(Pins.GPIO_PIN_D1, false, Port.ResistorMode.Disabled); bool bsState; if(bs == true) { bsState = bs.Read(); } } }}
I get an error message stating that "Operator '==' cannot be applied to operands of type 'Microsoft.SPOT.Hardware.InputPort' and 'bool' "
How do i deal with this. Also could anyone please help me in saving data to a memory card for a netduino plus 2 with detailed explanation. Thanks in advance.
#48827 reading data through a serial port on netduino plus 2
Posted by m.sainath on 28 April 2013 - 07:37 PM in Netduino Plus 2 (and Netduino Plus 1)
using System.IO.Ports;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;namespace barcode_scanner{ public class Program { public static InputPort bsr = new InputPort(Pins.GPIO_PIN_D0, false, Port.ResistorMode.Disabled); public static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); public static void Main() { SerialPort mySerialPort = new SerialPort("COM1"); mySerialPort.BaudRate = 9600; mySerialPort.Parity = Parity.None; mySerialPort.StopBits = StopBits.One; mySerialPort.DataBits = 8; mySerialPort.Handshake = Handshake.None; mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler); } public static void DataReceivedHandler( object sender, SerialDataReceivedEventArgs e) { led.Write(true); Thread.Sleep(1000); led.Write(false); Thread.Sleep(Timeout.Infinite); }
[color=rgb(102,102,102);font-family:'Segoe UI', Helvetica, Garuda, Arial, sans-serif;]I'm using the above code to receive data through a serial port connected to my netduino plus 2 via a breakout board (RS232 to TTL converter- [/color]http://www.embeddedm...-TTL-Converter/[color=rgb(102,102,102);font-family:'Segoe UI', Helvetica, Garuda, Arial, sans-serif;]). The data i want to receive is from a barcode scanner whose output is a RS232 female, so i use a RS232 male to male cable and then use the above mentioned breakout board to connect to netduino plus 2. Upon use of the above code led does not blink. All i want to do is blink the led when data is read from barcode scanner i.e., when the barcode scanner scans a barcode. Please help me resolve this. Thanks in advance.[/color]
#48883 reading data through a serial port on netduino plus 2
Posted by m.sainath on 30 April 2013 - 03:42 PM in Netduino Plus 2 (and Netduino Plus 1)
using System;using System.Net;using System.Net.Sockets;using System.Threading;using System.IO.Ports;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;namespace barcode_scanner{ public class Program { public static InputPort bsr = new InputPort(Pins.GPIO_PIN_D0, false, Port.ResistorMode.Disabled); public static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); public static void Main() { // write your code here SerialPort mySerialPort = new SerialPort("COM1"); mySerialPort.BaudRate = 9600; mySerialPort.Open(); Thread.Sleep(Timeout.Infinite); mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler); } public static void DataReceivedHandler( object sender, SerialDataReceivedEventArgs e) { led.Write(true); Thread.Sleep(1000); led.Write(false); } }}
i get An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.SerialPort.dll upon following the above changes.
- Netduino Forums
- → m.sainath's Content
- Privacy Policy