Estoy intentando enviar un comando a un PIC18F4550 de microchip con gambas3 en un ubuntu 10.04.
Tengo que enviar un comando que por ejemplo puede se "OUT 1 ON" (enciende un relé de la tarjeta de la placa).
He probado con el programa de ejemplo que viene pero el micro siempre me devuelve "FAIL" que es lo que devuelve si el comando que le llega al micro no es correcto.
Con gtkterm va bien (devuelve OK) pero con gambas no hay manera, he puesto la misma configuración:
port = /dev/ttyACM0
speed = 9600
bits = 8
stopbits = 1
parity = none
flow = none
Pero de nuevo "FAIL"
He visto que en el ejemplo lo que escribe en el puerto es
Citar:
y he probado con la linea comentada que hay encima:
Citar:
Sin éxito.
Con C# tengo un código que si que funciona, pero lo quería hacer con gambas que es mucho mas amigable con los formularios.
El codigo monodevelop es:
public string sendCommand(string command, int msTimeout)
{
discardStaleData(); //Ya llama al openPort
//openPort();
command += "\r"; //CR has to be added for the command to be executed
//Command is send with a short delay between each byte
foreach (byte bt in strToByteArray(command))
{
byte[] btArr = new byte[1];
btArr[0] = bt;
mySerial.Write(btArr, 0, btArr.Length);
System.Threading.Thread.Sleep(2);
}
System.Threading.Thread.Sleep(2); //Short delay before reading
return readLine(msTimeout);
}
public void discardStaleData()
{
openPort();
//Clear buffer just in case there is stale data
try
{
mySerial.ReadTimeout = 10;
mySerial.ReadExisting();
}
catch (System.TimeoutException)
{
//Nothing to do since we are cleaning buffer
}
}
{
discardStaleData(); //Ya llama al openPort
//openPort();
command += "\r"; //CR has to be added for the command to be executed
//Command is send with a short delay between each byte
foreach (byte bt in strToByteArray(command))
{
byte[] btArr = new byte[1];
btArr[0] = bt;
mySerial.Write(btArr, 0, btArr.Length);
System.Threading.Thread.Sleep(2);
}
System.Threading.Thread.Sleep(2); //Short delay before reading
return readLine(msTimeout);
}
public void discardStaleData()
{
openPort();
//Clear buffer just in case there is stale data
try
{
mySerial.ReadTimeout = 10;
mySerial.ReadExisting();
}
catch (System.TimeoutException)
{
//Nothing to do since we are cleaning buffer
}
}
Hos habeis encontrado con algo así? Si alguien me puede socorrer un poco se lo agradeceré eternamente.
No se si he buscado correctamente, pero no encuentro información y hace días que que busco y nada.Como podeis ver no soy ningún fiera de la programación.
Gracias!