|
I'm not sure. Perhaps using the fix by Greg Lapin will work. Change ASCII to UTF8 in the code.
Re: Only ascii characters up to 127dec are supported. All bytes above 127 are converted to the ? character.
> Greg Lapin wrote:
In CommPort.cs there is a command:
String SerialIn = System.Text.Encoding.ASCII.GetString(readBuffer,0,count);
and the "ASCII" term is defined as "Gets an encoding for the ASCII (7-bit) character set."
Changing this to "UTF8" fixes the 7-bit limit and allows 8-bit values to be displayed.
|
|
|
|
|
Thank you for your quick response.
I put in as your answer, but did not work.
It worked with the DEFAULT.
SerialIn System.Text.Encoding.Default.GetString String = (ReadBuffer, 0, count);
Thank you for teaching me where I should change.
Forgive me for disturbing you.
I changed the line that receives the LOCALECHO.
if (Settings.Option.LocalEcho)
{
outputList_Add (DateTime.Now.ToLongDateString () + "" + DateTime.Now.ToLongTimeString () + "" + MAIN + "\ n", sentColor);
}
It worked for the echo.
In the system I need to put the date in standard Japanese in front of the line that is captured from the serial.
Teach me where this line so I can change please.
Best Regards,
ocaccy
|
|
|
|
|
Hello Milkplus,
We can make the code to put the date in Japanese, taking the empty spaces with Trim (),
find a position with IndexOf (), taking a piece of string with substring (),
Transfomer with Convert.ToInt32 (), etc. ..
Let's go to the second part; Dynamic plotting with the result above.
Do you know anything to help us? I would like to join our project?
Come on, you're very good at this guy.
The code.
public void logFile_writeLine4(string stringOut)
{
stringOut=stringOut.Trim();
if(stringOut.Contains("01"))
{
int pos=stringOut.IndexOf("clean");
string XOVEx=stringOut.Trim().Substring(0,pos-2)+" "+DateTime.Now.ToLongDateString()+" "+DateTime.Now.ToLongTimeString()+"\n";
textBox5.AppendText(XOVEx);
string XOVE=stringOut.Trim().Substring(0,pos-2);
string varID=textBox5.Text.Substring(0,2);
int varIDint=Convert.ToInt32(varID);
listBox1.Items.Add(varIDint);
string varch2m=textBox5.Text.Substring(3,5);
int varch2mint=Convert.ToInt32(varch2m);
listBox2.Items.Add(varch2mint);
string varch7m=textBox5.Text.Substring(9,5);
int varch7mint=Convert.ToInt32(varch7m);
listBox3.Items.Add(varch7mint);
string varch10m=textBox5.Text.Substring(15,5);
int varch10mint=Convert.ToInt32(varch10m);
listBox4.Items.Add(varch10mint);
if(stringOut.Contains("Main")||stringOut.Contains("Run")||stringOut.Contains("Ver")||stringOut.Contains("2:"))
{
}
else
{
Stream myStream=File.Open("F:/USUARIOS/dtp2/SAIDAX/soIDLog.CSV",
FileMode.Append,FileAccess.Write,FileShare.Read);
if(myStream!=null)
{
StreamWriter myWriter=new StreamWriter(myStream,Encoding.UTF8);
myWriter.WriteLine(DateTime.Now.ToLongDateString()+","+DateTime.Now.ToLongTimeString()+","+XOVE);
myWriter.Close();
}
}
}
}
|
|
|
|
|
I'm trying to learn c#.
I'm working on termie to make it a sniffer for my microcontrollers projects.
Actually I send from my microcontroller a frame < data > < end of frame >.
In OnDataReceived(string dataIn) I've changed EndsWith, with my < end of frame >. After I try to parse the StringIn (0,4 => destination, 4, 8 => source, 8 ctrl, then data) to give it a fancy and more readable style.
I try different solutions, but everytime I get NullReferenceException in Invoke(new StringDelegate())
Where is the right place to make parsing of data?
This is my work (exception: Index out of range, Invoke(new StringDelegate(OnDataReceived), new object[] { dataIn });):
public void OnDataReceived(string dataIn)
{
string StringIn = null;
bool done = false;
// Handle multi-threading
if (InvokeRequired)
{
Invoke(new StringDelegate(OnDataReceived), new object[] { dataIn });
return;
}
// pause scrolling to speed up output of multiple lines
bool saveScrolling = scrolling;
scrolling = false;
// if we detect a line terminator, add line to output
int index = 0;
while (dataIn.Length > 0 &&(dataIn.EndsWith("\r\r\r\r")))
{
index = dataIn.IndexOf("\r\r\r\r");
StringIn = dataIn.Substring(0, index);
dataIn = dataIn.Remove(0, index + 4);
logFile_writeLine(AddData(StringIn).Str);
partialLine = null; // terminate partial line
done = true;
}
if (done == true)
{
DateTime date1 = DateTime.Now;
string Frame = " Time : ";
Frame = Frame + date1.ToString(("hh:mm:ss.fff"));
Frame = Frame + " Dest.: ";
foreach (char c in StringIn.Substring(0,4))
{
Frame = Frame + String.Format("{0:X2}", (int)c);
}
Frame = Frame + " Source : ";
foreach (char c in StringIn.Substring(4,4))
{
Frame = Frame + String.Format("{0:X2}", (int)c);
}
Frame = Frame + " Ctrl: " + String.Format("{0:X2}", (int)StringIn[9]);
infoLine = outputList_Add(Frame, receivedColor);
done = false;
}
// if we have data remaining, add a partial line
if (dataIn.Length > 0)
{
partialLine = AddData(dataIn);
}
// restore scrolling
scrolling = saveScrolling;
outputList_Scroll();
}
modified on Thursday, January 20, 2011 10:21 AM
|
|
|
|
|
If I was going to write termie again, I'd avoid invoke. It always gives me problems. A better way to handle it is with a "lock" on a shared buffer. The producer (comm thread) adds to the buffer and the consumer (UI thread) copies the buffer to another buffer and clears the shared buffer. Both use lock(buffer) before accessing it. Does that make sense? That may help.
|
|
|
|
|
Termie seems to work just great, and I'd like to use some of the code in a custom program of my own.
I've got 2 problems:
1) I'm a C# neophite I've gotten myself into a C# project, and I'm learning as I go (not the best way I realize).
2) I'm having problems switching comm ports in my program. When I startup, I do a com.Open(), and everything works just fine. But, my code needs to search through the available comm ports to find an attached device. Whenever I change port (com.Close(); Settings.Port.PortName = "COM10"; com.Open();) if a character is received, I can't Close() the port! It hangs up waiting for the thread to finish.
I know that I'm asking a lot, but do you have any idea what might be happening (remembering that I'm VERY much a C# novice at this point).
Steve
|
|
|
|
|
Hello.
I'm using Termie with an application which sometimes requires setting up a transmit delay (15 to 30 ms per line) to ensure that it is able to process correctly the transmitted file.
There is such a feature in HyperTerm and Tera Term.
In Tera Term :
Transmit delay = (x) msec/char (x) msec/line
Would it be possible to implement this feature in Termie ?
Thanks for your reply!
Eric
|
|
|
|
|
I like Termite's ability to handle non-standard baud rates, but wanted the ability to send a file.
I like Termie's ability to send a file, but wished you had kept the non-standard baud rate functionality.
I like the fact that both can be distributed as an exe/ini combination.
|
|
|
|
|
PS.... if there are road blocks you know of required to support non-standard baud rates, let me know!
Termite does some weird things in terms of what 'non-standard' baud rates can be specified and how they are quantized. I suppose maybe it has something to do with what the hardware will support.
|
|
|
|
|
system.io.ports.serialport.baudrate
can be set to anything from 0 to the max baud rate for the device.
You could easily modify the baud rate table in the code for Termie
Int32[] baudRates = {
100,300,600,1200,2400,4800,9600,14400,15000,19200,
38400,56000,57600,115200,128000,256000,0
};
I added the non-standard baud rate 15000. Hope that helps.
|
|
|
|
|
You suppose correctly! Not all serial ports (or virtual serial ports) support non-standard baud rates. When you pass in a baud rate that the hardware does not support, the serial driver may return "failure", but it may also (silently) clamp the baud rate to the nearest value that it does support.
In my experience, the standard serial ports on PC motherboards rarely support non-standard baud rates. If you use USB-to-RS232 converters, use one with an FTDI chip. Most (cheap) converters have a Prolific chip, its support for non-standard baud rates is not great.
I am the author of Termite, by the way, and found out the above when using Termite in a MIDI chain (MIDI is basically RS232 current-loop with a baud rate of 31250 bps).
|
|
|
|
|
Hi milkplus,
I have a couple of questions:
1. When sending data, I need to move the cursor about 10 positions to the right to delete previous characters before I enter new text. How could I do that? it appears that there is no ascii characters for the right or left arrows. Is there a way to overwrite current text?
2. What code changes do I have to make to emulate vt100?
3. In regard to sending hex code:
Do I need to send ff at the end of the stream? i.e. \x01\x02\x5f\ff or \x01\x02\x5f is fine (without ff at the end).
Thanks for sharing such a great application!
xplorer2k
|
|
|
|
|
This source code is just cool! i've been looking for this kind of project since long ago, but after i opened the .zip code, wow! There's so many files.
i want to achieve: sending data from a PS3 controller (playing game in my PC with a PS3 controller) through RS-232 to a PIC 16f84 IC (8 channel servo controller).
Is it possible to include all the code into 1 file for easy reading?
Pls reply, i really curious & want to try the code out!
Thank you very much!!!!
modified on Saturday, September 12, 2009 10:54 AM
|
|
|
|
|
Thanks for your effort and sharing it with us. It is grate and gave me lot of help that I have been searching for a week. Thanks again and keep it up.
|
|
|
|
|
I'm pretty new to programming (anything) but...
I have this string:
BE EF 10 05 00 c6 ff 11 11 01 00 01 00
it's to turn on a video projector.
I cant seem to get it to work in hex mode... any ideas on a way to convert it?
|
|
|
|
|
some values of hex work but others send 3f.
\x5a sends 3F instead.
I'm I doing something wrong?
Is there a way to insert ascii and hex value in the file and send
them all?
Thanks
|
|
|
|
|
Work's great! Thanks for sharing Termie with us. It saved me a lot of time getting a serial port interface up and running in an application I am working on in C#. Thanks again
|
|
|
|
|
is there possibility to enter some binary code that termie will send properly ?
|
|
|
|
|
You can send binary hex codes like this
\x01\x02\x5f\ff
|
|
|
|
|
hm so what am i doing wrong ?
cause i would like to send code: 11111111 00000011 10111011 10010100
dec it is: 255 3 187 148
and hex: ff 03 bb 94 -> so as You told me i have written \ff\03\bb\94
but withoud any effects :/
in general,i would like to sent commands to my robot (based on sk18) and it accepts frames like i have written above in binary (it works with dedicated soft)
do You have any clues ?
thanks in advance
|
|
|
|
|
I haven't tried it, but it looks like what you should be using is \xff\x03\xbb\x94 instead of \ff\03\bb\94.
|
|
|
|
|
Thank you for sharing Termie.
I tried to use Termie to send a file to a microprocessor. It's a ServoPod from Newmicros. I was not able to send the file. The file needs to be sent one line at a time with each line ending in a CR. The next line needs to wait for a CR-LF to be sent by the microprocessor (line pacing).
Is it possible to setup Termie to send a single line from a text file then wait for a CR-LF before sending the next line? The microprocessor is compiling the text as it is sent and needs a little time to process each line of text.
Also, if an error occurs (such as an unrecognized word) the microprocessor sends back a " ? " (that's a space, question mark, space). Is it possible to make Termie abort a file transfer if a certain character string is sent back?
I also saw the word "Able" being sent by Termie. Is it possible to disable any extra text (other than the text from the file) from being sent?
Even if none of the above is possible with Termie, I still appreciate you making your software available to the public.
Thanks,
Gary
|
|
|
|
|
The type of "send file" you describe is very specific to your needs and I wouldn't put that into this simple and general purpose app. Even adding a customizable protocol with acknowledge and error sequences is more than I want to implement. If you want to do it yourself, look for these lines in form1.cs
String text = System.IO.File.ReadAllText(dialog.FileName);
CommPort com = CommPort.Instance;
com.Send(text);
This is where you'll want to add the logic you describe. You might even want to put it on a separate thread and add a progress bar since it will hang up the UI until you are done sending but that is more complicated.
hope that helps
|
|
|
|
|
More detail on how to use the source code would be nice - even 1 snippet.
|
|
|
|
|
I noticed that only ascii characters up to 127 decimal are supported by Termie.
If a byte is read whose value is greater than 127, it is converted to the ? character (3F) in hex.
The same thing applies to hex writes. Any hex value larger than 7F (127dec) is converted to a ? char and then sent over the COM port.
Would it be possible to modify Termie to support hex reads/writes up to FF?
Thanks!
|
|
|
|