Foros del Web » Programación para mayores de 30 ;) » .NET »

Puerto Serie RS232

Estas en el tema de Puerto Serie RS232 en el foro de .NET en Foros del Web. Hola: Utilizando el MonoDevelop en Linux, creé en gtk# un proyecto, coloqué sólo un botón en el formulario. Sólo quiero abrir el puerto serie y ...
  #1 (permalink)  
Antiguo 23/02/2009, 16:42
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 17 años
Puntos: 8
Puerto Serie RS232

Hola:

Utilizando el MonoDevelop en Linux, creé en gtk# un proyecto, coloqué sólo un botón en el formulario. Sólo quiero abrir el puerto serie y enviar un byte al puerto serie.

El código completo hasta ahora es:


Código:
// MainWindow.cs created with MonoDevelop
// User: metaconta at 20:59 23/02/2009
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
//
using System;
using Gtk;
using System.IO.Ports;

public partial class MainWindow: Gtk.Window
{	
	public MainWindow (): base (Gtk.WindowType.Toplevel)
	{
		Build ();
	}
	
	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
	{
		Application.Quit ();
		a.RetVal = true;
	}
	
	public SerialPort mySerial;

	protected virtual void OnButtonTClicked (object sender, System.EventArgs e)
	{
		mySerial = new SerialPort("/dev/ttyS0", 9600, Parity.None, 8, StopBits.Two);
		mySerial.Open();
		byte[] mBuffer = new byte[1];
		mBuffer[0] = 0x74; // LA letra t.
		mySerial.Write(mBuffer, 0, mBuffer.Length);
		mySerial.Close();
	}
}

Al ejecutar se ejecuta sin problemas, pero lo hay al pulsar el botón y me muestra este menaje de errores o algo parecido y no envía nada al puerto serie y quiero resolver este problema.


Marshaling clicked signal
Exception in Gtk# callback delegate
Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.IOException: Permiso denegado
at System.IO.Ports.SerialPortStream.ThrowIOException () [0x00012] in /usr/src/packages/BUILD/mono-2.0.1/mcs/class/System/System.IO.Ports/SerialPortStream.cs:299
at System.IO.Ports.SerialPortStream..ctor (System.String portName, Int32 baudRate, Int32 dataBits, Parity parity, StopBits stopBits, Boolean dtrEnable, Boolean rtsEnable, Handshake handshake, Int32 readTimeout, Int32 writeTimeout, Int32 readBufferSize, Int32 writeBufferSize) [0x0001e] in /usr/src/packages/BUILD/mono-2.0.1/mcs/class/System/System.IO.Ports/SerialPortStream.cs:36
at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPortStream:.ctor (string,int,int,System.IO.Ports.Parity,System.IO.P orts.StopBits,bool,bool,System.IO.Ports.Handshake, int,int,int,int)
at System.IO.Ports.SerialPort.Open () [0x00078] in /usr/src/packages/BUILD/mono-2.0.1/mcs/class/System/System.IO.Ports/SerialPort.cs:563
at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPort:Open ()
at MainWindow.OnButtonTClicked (System.Object sender, System.EventArgs e) [0x00018] in /home/metaconta/Prueba_02/Prueba_02/MainWindow.cs:28
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00057] in /usr/src/packages/BUILD/mono-2.0.1/mcs/class/corlib/System.Reflection/MonoMethod.cs:157
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00071] in /usr/src/packages/BUILD/mono-2.0.1/mcs/class/corlib/System.Reflection/MonoMethod.cs:167
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /usr/src/packages/BUILD/mono-2.0.1/mcs/class/corlib/System.Reflection/MethodBase.cs:110
at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000b4] in /usr/src/packages/BUILD/mono-2.0.1/mcs/class/corlib/System/Delegate.cs:422
at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00018] in /usr/src/packages/BUILD/mono-2.0.1/mcs/class/corlib/System/MulticastDelegate.cs:71
at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in /usr/src/packages/BUILD/mono-2.0.1/mcs/class/corlib/System/Delegate.cs:394
at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) [0x0004f] in /usr/src/packages/BUILD/gtk-sharp-2.12.6/glib/Signal.cs:195
at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x0000c] in /usr/src/packages/BUILD/gtk-sharp-2.12.6/glib/SignalClosure.cs:118
at GLib.SignalClosure.MarshalCallback (IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data) [0x0007a] in /usr/src/packages/BUILD/gtk-sharp-2.12.6/glib/SignalClosure.cs:146
at GLib.ExceptionManager.RaiseUnhandledException(Syst em.Exception e, Boolean is_terminal) in /usr/src/packages/BUILD/gtk-sharp-2.12.6/glib/ExceptionManager.cs:line 58
at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data) in /usr/src/packages/BUILD/gtk-sharp-2.12.6/glib/SignalClosure.cs:line 173
at Gtk.Application.gtk_main()
at Gtk.Application.Run() in /usr/src/packages/BUILD/gtk-sharp-2.12.6/gtk/generated/AboutDialog.cs:line 1
at Prueba_02.MainClass.Main(System.String[] args) in /home/metaconta/Prueba_02/Prueba_02/Main.cs:line 18
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar
  #2 (permalink)  
Antiguo 23/02/2009, 16:50
Avatar de Peterpay
Colaborador
 
Fecha de Ingreso: septiembre-2007
Ubicación: San Francisco, United States
Mensajes: 3.858
Antigüedad: 16 años, 8 meses
Puntos: 87
Respuesta: Puerto Serie RS232

parece q el problema son los permisos sobre el dispositivo del puerto como si requirieras un permiso adicional en el puerto.

revisa esto

http://www.gphoto.org/doc/manual/per...ns-serial.html
__________________
Curso WF4
http://cursos.gurudotnet.com/ DF
Aprende HTML5
  #3 (permalink)  
Antiguo 24/02/2009, 11:31
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 17 años
Puntos: 8
Respuesta: Puerto Serie RS232

Cita:
Iniciado por Peterpay Ver Mensaje
parece q el problema son los permisos sobre el dispositivo del puerto como si requirieras un permiso adicional en el puerto.

revisa esto

http://www.gphoto.org/doc/manual/per...ns-serial.html
Me ha funcionado.

Muchísimas gracias mi muy distinguido amigo.
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:34.