talk to boe bot using c# with eb500
i want to create a program with c# to talk to my boe bot using eb500. I have set it up as a com port and i created a program that sends the data over to the boe bot using c# but the boe bot cannot read what i am sending over?
i was wondering if anyone knew how to open up the com port with c# and what settings you need? i have been able to open it up and send data, but so far boe bot reads it as Smile and not a string?
i should also note that i am trying to send it chars.
i want to use my computer as the brains of the system and have the boe bot be controled with it. I am going to hook up a real time cam system to it so it can track objects and tell what kind of object it is and so on.
thanks for all the help..
i was wondering if anyone knew how to open up the com port with c# and what settings you need? i have been able to open it up and send data, but so far boe bot reads it as Smile and not a string?
i should also note that i am trying to send it chars.
i want to use my computer as the brains of the system and have the boe bot be controled with it. I am going to hook up a real time cam system to it so it can track objects and tell what kind of object it is and so on.
thanks for all the help..
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
code below:
SerialPort sp = new SerialPort();
sp.BaudRate = Convert.ToInt32(b_p_sec.Text);
//sp.DataBits=Convert.ToInt32(data_b.Text);
//sp.pa
//sp.Parity
sp.PortName =comport.Text;
Then i send the command to the robot:
// send command to robot..
Encoding my;
//byte[noparse]/noparse testa = new byte[noparse][[/noparse]50];// set the array..
try
{
//write line to serial port
//byte array[noparse]/noparse;
//array='H';
// works but only with one char???
//my = sp.Encoding;
sp.Write(sendbox.Text);
// sp.Write(
//StopBits test;
//test.
//sp.StopBits
//sp.
//sp.WriteLine(sendbox.Text);
//clear the text box
sendbox.Text = "";
}
catch (System.Exception ex)
{
MessageBox.Show( ex.Message);
}
It works and it looks like it just sends the first letter? when i do this in Hyper Terminal it works fine and sends everything? But C# must use the serial ports different or something? i have not tried to rev from the robot yet?
anyone know what might be the problem? or should i use C++ or something to do this?
I can talk to my robot and it gets the first letter like i said but it just does not seem to get the rest. I had the rev on the bot set to an array of bytes so i should have the room.
The code is there for both sides (the BoeBot and the PC. Below is the Serial Port section from the MSRS - BoeBotControl.cs file.
public bool Connect(int serialPort, out string errorMessage)
{
if (serialPort <= 0)
{
errorMessage = "The Boe-Bot serial port is not configured!";
return false;
}
if (connected)
{
Close();
}
try
{
string ComPort = "COM" + serialPort.ToString();
_serialPort = new SerialPort(ComPort, 9600, Parity.None, 8, StopBits.One);
_serialPort.Open();
_serialPort.DiscardInBuffer();
errorMessage = string.Empty;
connected = true;
return true;
}
catch (Exception ex)
{
errorMessage = string.Format("Error connecting Boe-Bot to COM{0}: {1}", serialPort, ex.Message);
return false;
}
}
public void Close()
{
if (!connected)
return;
connected = false;
if (running)
{
running = false;
Thread.Sleep(100);
}
if (_serialPort != null && _serialPort.IsOpen)
{
_serialPort.Close();
_serialPort = null;
}
}
so that kind of sucks for sending data to the computer.
because i really need this all to be done in real time. so the computer can do more work.
But talking back and forth between C# and boe bot works. All you have to do is use the System.IO.Ports.. i had to send the data and get the data using bytes. giving that i only have 2 byte to send of data does not really give me all the options i was hoping for.
well i wanted to close this out should some ever search on this..
I dont know if you are still looking for an answer or if this can help..
www.codemammoth.com/ShowCode.php?Code=16