Society of Robots - Robot Forum
Software => Software => Topic started by: bootstrap on March 05, 2008, 01:58:29 AM
-
Hi,
I have just started using sensors and I did the coding for ADC.I am able to get the ADC values using the Hyperterminal.But I want to build real time graphs using C in DevCpp (Windows).Any sample code which will help me read the data from the serial port (9600-8-N-1) in DevCpp (windows).
Thanks in advance
-
I had a class once to do this. Let me look for it.
The only problem is, it's a class, so you'll need c++.
what are you going to use for the UI, if you build graphs? or it's simply aquire data-generate image from a console program.
If you develop a scope-like program, please let me know, i wanted to make something like this a long time ago :P
-
Here you go.
-
Here you go.
I am getting the following linker error
E:\Dev-Cpp\lib/libmingw32.a(main.o)(.text+0x106):main.c: undefined reference to `WinMain@16'
-
let's try and figure that out.
first, when we get a random class off the internet, we suppose it's a simple, raw, algorithm or API usage. so we don't use any GUI.
is your project supposed to be a GUI program?
WinMain is the equivalent of main() in a console program.
-
let's try and figure that out.
first, when we get a random class off the internet, we suppose it's a simple, raw, algorithm or API usage. so we don't use any GUI.
is your project supposed to be a GUI program?
WinMain is the equivalent of main() in a console program.
I also have to use Open CV (so its GUI).Can you please tell me how to solve the linker error?Did the program work fine for you?Did you create a project and then passed a parameter to it?
-
No, I simply let values scroll in a console terminal.
I don't want to be a nuissance, but if you don't know how to adapt a console class to a GUI class, you should definitely learn some C++.
I've tested the class in a console environment. There was one instance when I haven't done that, using openGL for drawing samples and I haven't found a single problem.
Take steps to meet all the requirments imposed by your GUI framework: having a winmain, or using a macro to implement the graphic env, or whatever it asks for (i'm not familliar with openCV).
You can't simply add my file (main.cpp) into your project and expect it to work, since my file has a main function and it prints data to cout. You'll have to use the main function of your graphic env (which will generate winmain, anyway), instantiate a class SFile mySerial
, open it (mySerial.open(1,9600)
) and then graph or show all the data you'll read using a label, button or whatever your GUI permits.
-
No, I simply let values scroll in a console terminal.
I don't want to be a nuissance, but if you don't know how to adapt a console class to a GUI class, you should definitely learn some C++.
I've tested the class in a console environment. There was one instance when I haven't done that, using openGL for drawing samples and I haven't found a single problem.
Take steps to meet all the requirments imposed by your GUI framework: having a winmain, or using a macro to implement the graphic env, or whatever it asks for (i'm not familliar with openCV).
You can't simply add my file (main.cpp) into your project and expect it to work, since my file has a main function and it prints data to cout. You'll have to use the main function of your graphic env (which will generate winmain, anyway), instantiate a class SFile mySerial
, open it (mySerial.open(1,9600)
) and then graph or show all the data you'll read using a label, button or whatever your GUI permits.
Izua ,I now know what the problem is .Yours zipped file has only sfile.cpp and sfile.h .There is no main block (or main.cpp) in it.Thats why I was getting such error.I think I need to create my own main block and call the functions in sfile.cpp
-
Izua
I am getting the following errors.Dont know why.!!!
main.o(.text+0x158):main.cpp: multiple definition of `SFile::Open(unsigned int, unsigned long)'
SFile.o(.text+0x58):SFile.cpp: first defined here
main.o(.text+0x388):main.cpp: multiple definition of `SFile::Read(void*, unsigned long, unsigned long&)'
SFile.o(.text+0x288):SFile.cpp: first defined here
main.o(.text+0x630):main.cpp: multiple definition of `SFile::Write(void const*, unsigned long, unsigned long&)'
SFile.o(.text+0x530):SFile.cpp: first defined here
main.o(.text+0x87e):main.cpp: multiple definition of `SFile::ReadByte(unsigned char&)'
SFile.o(.text+0x77e):SFile.cpp: first defined here
main.o(.text+0x8c8):main.cpp: multiple definition of `SFile::WriteByte(unsigned char)'
SFile.o(.text+0x7c8):SFile.cpp: first defined here
main.o(.text+0x918):main.cpp: multiple definition of `SFile::SetCommMask(unsigned long, unsigned char)'
SFile.o(.text+0x818):SFile.cpp: first defined here
main.o(.text+0x9ce):main.cpp: multiple definition of `SFile::WaitCommEvent(unsigned int, unsigned long*)'
SFile.o(.text+0x8ce):SFile.cpp: first defined here
main.o(.text+0xc10):main.cpp: multiple definition of `SFile::SetBaudRate(unsigned long)'
SFile.o(.text+0xb10):SFile.cpp: first defined here
main.o(.text+0xc94):main.cpp: multiple definition of `SFile::BytesInComm()'
SFile.o(.text+0xb94):SFile.cpp: first defined here
main.o(.text+0xce4):main.cpp: multiple definition of `SFile::PurgeComm()'
SFile.o(.text+0xbe4):SFile.cpp: first defined here
main.o(.text+0x100):main.cpp: multiple definition of `SFile::Close()'
SFile.o(.text+0x0):SFile.cpp: first defined here
collect2: ld returned 1 exit status
make.exe: *** [Project1.exe] Error 1
Execution terminated
-
Any idea about how to eliminate the errors?
-
please post your main() and be sure to use include guards. looks like a idempotence problem to me.
-
please post your main() and be sure to use include guards. looks like a idempotence problem to me.
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include <E:\robotics\serialtry\sfile\SFile.h>
#include <E:\robotics\serialtry\sfile\SFile.cpp>
int main()
{
SFile myserial;
printf("ADC values\n");
myserial.Open(1,9600);
getch();
return 0;
}
-
So what is the problem in the code which is causing the error?
-
please post your main() and be sure to use include guards. looks like a idempotence problem to me.
"izua" i solved the problem regarding the linker errors...My question is say u have the ADC values coming from the serial port.I was able to get the values in the hyper terminal.Were you able to read the values with your program?(Which functions you used for this?)
-
You're not seeing any values because you aren't invoking the class member which returns data from the buffer.
You must use classinstance.read/write/readbyte/writebyte.
Anyway, i attached my original test application, with main. Hope this works.
-
Izua I am drawing a graph with the adc values.I was able to build the graph.But for that I used (int)b , i type casted the byte to interger.But this is not proving to be accurate.What I mean is if i have the adc values say 550,552 in terms of integers rather than the (int)b I will be able to interpret the graph in a better way.How shall I convert the byte 550 to integer 550 value.Please suggest
-
this depends a lot on how are you receiving your data.
explain me the format the electronics send data to the port.
what library are you using to plot the graph?
-
izua I was successuflly able to draw the graph.I am sending you the some of the graphs generated real time .The values were obtained using potentiometer attached to ADC0 on atmega8.Also I have this MMA7261QT 3D accelerometer from freescale. I tried moving it around but did not observe any change in the output voltage level.It has been set to a sensitivity of 2.5 G.May be the accelerometer is damaged..?? I dont know why it is not showing any variations in the values.
-
this depends a lot on how are you receiving your data.
explain me the format the electronics send data to the port.
what library are you using to plot the graph?
Hey I want to send characters and strings using your program .What functions shall I use .Please give an example Izua.Thanks in advance .
-
maybe the acce needs a pullup or something. check datasheet.
anyway dude, really helpful, you could have at least explained the library used for UI (as my initial request). I'm not even thinking of asking for sourcecode. dammit.
anyway, to send strings, just decide what exactly a "string" is, and make a function to read each byte in the string, know when to end, and send the bytes out one by one.
-
this depends a lot on how are you receiving your data.
explain me the format the electronics send data to the port.
what library are you using to plot the graph?
Dear Izua ,I have used OpenCV to draw the graphs.I have use the function to draw lines between two points.I converted the ADC valuse to integer and used it as the vertical sepration between two points have the same X value.After that I incremented X value by unity.
Also is there a function in your headfer file to send chars or strings?
-
Hey bootstrap
Did you ever get it to work? I've recently had a need for something like this so I'm going to try it out soon too . . .
-
For anyone else who wonders how to send out C strings.
char gigi[50]="testing testing..\n";
char *p;
p = &gigi[0];
while (*p != 0)
{
com.WriteByte(*p++);
}