|
my friend my computer will die soon second time my computer closed itself.
i just want to sequence my 6 datas.
|
|
|
|
|
Im not sure what else to tell you without seeing the code as a whole. What I have posted should work. Com ports are pretty easy to work with, just make sure its opened correctly, then read the data and do what you need to do with it.
|
|
|
|
|
i have done it many times.my problem is that:
i have a simulation project in wpf.so my serial datas will will simulate my robot arm s axises.for example:i send from microcontrolor to computer this:
for(;;)
{
delay_ms(1);
putc(value1);
putc(':');
putc(value2);
putc(':');
putc(value3);
putc(':')
putc(value4);
putc(':');
putc(value5);
putc(':');
putc(value6);
}
so i must get datas like this: "value1" for "axis 1","value2" for "axis2" ....
now could i explain my problem?
|
|
|
|
|
Ok, try concatinating all values into one string, then sending that string to the port all at once.
putc(value1 & ":" & value2 & ":" & value3 & ":" & value4 & ":" & value5 & ":" & value6);
Not sure what language you are using to send the information, so may need a different concatenation value. Then, when you recieve the data, you will get the whole string at once, and the Split() command will split all the values so data[0] will hold value1, data[1] will hold value2 and so on.
|
|
|
|
|
Sorry, but I doubt the entire concept of your project.
1)
Reality check: you want to send 6 bytes of data at 9600 Baud ?
with 1 start bit, 1 stop bit, no parity bit, a byte takes 10 bit times (a bit time is
1 second divided by the baudrate), that leads to a maximum of 960 bytes per second
(lets call this 1000 bytes per second, or 1 msec/byte for easier calculations).
Assuming you could send just 6 bytes (i.e. no overhead)
you will need almost 6 msec to transfer the amount of data you want to transfer every msec !?!?
2)
if 9600 Baud is the maximum your serial port (PC or target) can support, you are stuck.
You need more bandwidth, i.e. a higher baudrate, or a different interface hardware all together;
alternatively (and preferably, assuming data is not changing much) you should select some setup
with buffering+compression at the producer side (target), and buffering+decompression
at the consumer side (PC).
3)
you dont need separation characters between the six bytes, they serve no purpose;
you do need something that shows which byte is the first of a series of six.
Lets assume you use 7 bytes: 1 special character indicating "start of data", followed
by 6 data bytes. Your "start of data" value might also occur in one of the data bytes,
and hence you could have a case of mistaken synchronization, but if you test for that
and react properly, it will solve itself after a while (unless you are really unlucky;
to understand assume 5 of the 6 values you need to send happen to also have that special
value: how then can you tell to what channel belongs the one byte that differs ???)
4)
It will not be obvious to get the PC listen to the serial data in real-time; PCs are
not good in real-time stuff, they tend to do a whole lot of things, some in foreground,
some in background, and typically fast enough to satisfy the human user (who tolerates
delays of 10 or 100 msec, and occasionally a full second).
If you need better, you must work with "real-time" priorities, which easily will ruin
the behavior of all other processes unless you get everything correct, not a simple job.
5)
The normal way to connect a device (such as a robot arm) to a computer (such as a PC)
is by having a smarter target that executes intelligent commands, and reports higher-level
results (things like: rotate 20 degrees per second for the next 3 seconds; and "rotation'
done; new position=...". At that pace, you can easily have the PC follow the target.
Compare this with a printer: you send one byte to instruct it to print one character,
the PC does not control the paper movement, the head movement, the ink nozzles, the ribbon,
whatever; and the feedback is "page done" or "out of paper", not "paper has moved another
tenth of an inch".
6)
it is my conviction the requirements and/or the concept of this project exceed your
current technical skills and expertise, especially on PC side (embedded systems are easier
to program, and sending data is easier than correctly receiving it!).
You will need to rethink, and you probably will need much more help than any CodeProject forum
can offer you.
Anyway, I hope some of the above information will help you somehow.
|
|
|
|
|
i didnt do it:(i tried many codes but i didnt i will try more i must do it.thanks All of
|
|
|
|
|
If your micro is sending indivdual characters then in most cases the DataReceived event will be fired the number of times the characters are sent, i.e. you're trying to send 6 characters but by using 6 individual putc s it will fire off 6 DataReceived events. The best way would be to have a buffer to do something like this:
List<byte> buffer = new List<byte>();
private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
buffer.Add(serialPort.ReadByte());
if (buffer.Length == 6)
{
YourFunctionCall(buffer.ToArray());
buffer.Clear();
}
} The problem you mentioned in the other thread about Invoke is basically because Windows is using a different thread to receive data from the SerialPort, this is the one which is the owner of the DataReceived event. If you want to update for example some textboxes with teh values you receive you will have to do something like this:
private delegate void UpdateTextBoxes(byte[] values);
private void YourFunctionCall(byte[] values)
{
this.Invoke(new UpdateTextBoxes(this.UpdateTextBoxes));
}
privaet vodi UpdateTextBoxes(byte[] values)
{
this.txt1.Text = values[0].ToString();
this.txt2.Text = values[1].ToString();
} You might want to take a look at my article[^] which looks into this problem.
|
|
|
|
|
if i cant solve this problem i will write 1000000000 messages: ).it s so easy but it s not easy in real application i will try last helper 's codes i wish i can solve
|
|
|
|
|
I would try keeping an internal buffer as in my example because there is no guarantee of how Windows will receive the data, although the serial port has one of the highest IRQs of any hardware if Windows decides to go and do something then it decides to go and do it. I had to do something similar when parsing NMEA data from a GPS receiver, lines would come in a bit at a time.
|
|
|
|
|
i slept yesterday 03:30 at night i cant solve.i m not good at in visual c# so much.i have tried your codes but when i debug project so i see this:
"Visual Studio can not start debugging because the debug target 'C:\my project location\windowsapplication1.exe"' is missing.Please buld the project ........"
but i didnt anything wrong i can go mad soon
|
|
|
|
|
Hi All;
I am building a Windows form with multiple panels. I have a large panel as the base on the form, with a tab control on top of it, docked to fill, and multiple panels on the tab control. The base panel is docked to top of the form, with another panel below it, docked to the bottom. I also have a tool bar, and menu bar docked to the top of the form above the base panel. The problem I am having is that when I resize the form, I get a vertical scroll bar, but no horizontal scroll bar. I have autoscroll set to true, so not sure what the issue is. Do the panels on the tab control, or the tab control itself interfere with the horizontal scrolling?
|
|
|
|
|
Hi,
I have a ParentForm (FormMDI) and tow ChildForm : FormChild1, FormChild2
- Step1 : Open FormChild1 by Menu
FormChild1 f = new FormChild1();
f.MDIParent=this;
f.show();
- On FormChild1 I have a button when clicked it can open FormChild2 but FormChild2 still inside FormMDI.
Thank
Hoangsamac
|
|
|
|
|
hoangsamac wrote: On FormChild1 I have a button when clicked it can open FormChild2 but FormChild2 still inside FormMDI.
OK. It would probably help to see the code that creates your second child form. You showed the code that creates the first child, which apparently works fine. And on which form does this code sit?
|
|
|
|
|
Hi,
In ParentForm:
<br />
Memuitem_clicked(sender,e)<br />
{<br />
FormChild1 f = new FormChild1();<br />
f.MDIParent = this<br />
f.show();<br />
}<br />
My first child (FormChild1) contain a button and event:
<br />
button1_clicked(sender,e)<br />
{<br />
FormChild2 f = new formChild();<br />
f.MDIParent = ???
f.show();<br />
}<br />
In VB.Net,I see can do this
hoangsamac
|
|
|
|
|
Child form creation should really be left up to the parent form, but, to make yours work:
button1_clicked(sender,e)
{
FormChild2 f = new formChild();
f.MDIParent = this.Parent;
f.show();
}
|
|
|
|
|
Thank you very much !,
I did but code is:
f.Parent=this.ParentForm;
hoangsamac
|
|
|
|
|
Bitmap[] bitmaps = new Bitmap[42];
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello everyone,
I try to create an add-in C# for Visual Studio 2005. I want to create a toolbar look like Visual Assist X but I don't know how. And I want to customize right-click-menu of TextEditor in VS 2005.
I have too little ebook C# about add-in. May you introduce or send me some ebooks? Thanks lots.
You're very nice to help me. Thanks lots.
imagic
|
|
|
|
|
Add-ins are cool, but they are an advanced topic and will require lots of reading and lots of TESTING to understand. If you haven't had a lot of experience, you may have to wait a while before you will understand it. I've been doing this stuff for 25 years and I had a lot of trouble getting started, which is why my Source control program isn't released yet. What I'm saying is, this topic is wicked confusing, and you just need to jump in and sink or swim.
Take what you know so far and try making something simple, then come back here when you have some more specific questions. Sounds like you have a good start with some materials to read, and here's another article you can try to help you get started. Good luck!
http://www.c-sharpcorner.com/UploadFile/mgold/AddIns11292005015631AM/AddIns.aspx[^]
And note: by something simple I mean an add-in that puts up a toolbar that doesn't do anything, and a context menu that doesn't do anything. So many programmers want to start with more than that... always start with what I call "The Null Program" which just sets up the runtime environment and exits. It's even more basic than Hello World, and I start every new project by actually compiling and running that program... even after 25 years.
|
|
|
|
|
Jasmine2501 wrote: Add-ins are cool, but they are an advanced topic and will require lots of reading and lots of TESTING to understand. If you haven't had a lot of experience, you may have to wait a while before you will understand it. I've been doing this stuff for 25 years and I had a lot of trouble getting started, which is why my Source control program isn't released yet. What I'm saying is, this topic is wicked confusing, and you just need to jump in and sink or swim.
So true, so true.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Thanks.
I can create a simple add-in such as adding a text, calling a command intellisense, calling a command about region... I think I can customize ToolBox (just like how to customize MenuBar) , but I can't customize ToolBar by that way.
Can you help me ?
Thanks lots.
-- modified at 5:06 Monday 25th June, 2007
imagic
|
|
|
|
|
Your question is too general. You need to be more specific about what problem you are having. That's why you got flamed. We can't answer this for you in a timely manner. A good answer to your question would be many pages long. There are probably tutorials on the subject, but I assume you have read them already... you know, since you are posting a forum question.
You just need to be more specific in your question. Define your problem carefully and make a new thread. This one is dead and buried.
|
|
|
|
|
Have you ever used Visual Assist X ? When we install it, a new toolbar appears in Visual Studio .NET and some new item appear in right-click-menu . I want to do something like it.
Thanks
imagic
|
|
|
|
|
Yeah I know what you're talkin about. That tutorial doesn't really cover it... you need to look into the technical documentation and figure it out yourself, building on your knowledge of toolbars and context menus in standard forms, combine that with what you know about Add-ins, and figure it out.
This is an advanced topic and you will not find an article that simply tells you how to do it. This is where programming gets fun... embrace the problem and dive into it and figure it out as you go along. Nobody can help you do that. It is going to take hours, maybe days, of research, study and experimentation. The subject is difficult, and you are going to have to do a lot of work to figure it out. Accept that and stop asking for someone to hand-hold you through it. Dig in and get to work. I would help you if I could, but I can't move your fingers for you...
Everyone else ignored this question... you need to think about why. I answered it because I like to bitch at n00bz.
|
|
|
|
|
I have a central database in Sql server Express 2005 in my server computer. I want to connect it through my another client terminal.How can i make the connection & what configurations should i change?
Code or help apprecicated both in VB.Net and C#
Thank You!
X
|
|
|
|
|