Hi,
I am creating an interface which contains the listbox(C# .net micro framework). When the listbox item is seletected, it will send a character to the serial port and show a "send command" screen. When receiving the data from serial port, it will show another "receive command" screen. The problem i am facing now is the program not able to show out the "receive command" screen. The following is some part of the code:
public class MainMenu : PresentationWin dow
{
public MainMenu(myAppl ication app)
: base(app)
{
System.Threadin g.Thread serialThread = new
System.Threadin g.Thread(update Data);
serialThread.St art();
// do something here
}
public void updateData()
{
while (true)
{
importData();
}
}
int bytecount = 0;
public int importData()
{
UTF8Encoding enc = new UTF8Encoding();
byte[] buffer = new byte[32];
count = serialPort.Read (buffer, 0, buffer.Length, 1000);
int count;
if (count > 0)
{
serialPort.Writ e(buffer, 0, count);
bytecount += count;
new WarningScreen(m yApp);
}
return byteCount.ToStr ing();
}
}
public class WarningScreen : PresentationWin dow
{
public WarningScreen(m yApplication app)
: base(app)
{
// do something here...
}
}
I think maybe is because the while loop part cause the problem, but i don't
have any idea to solve it. Is there anyone can help me?
Thanks,
Celine
0 3948 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: ^CeFoS^ |
last post by:
Hello to everybody,
I've done an application that draws in a frame the trajectory of a
robot. The robot position is readed through the serial port, and
several commands are wrote through the same port to change the
direction of the robot.
The trajectory frame is managed by an applet, and the project works
good when the applet is called by a html document allocated in the
same local machine under W98 where the classes and the serial port...
|
by: rusttree |
last post by:
Many moons ago, I took a class in embedded control at school. The
course focused on a micro-controller mounted on a small electric car
that was programmed using simple C code. The micro-controller chip had
several pins, some of which were for output and some were for input.
The crux of the project was to make the program set the ouput pins to
high or low to drive the servos and motors and read the input pins that
were attached to various...
|
by: halukg |
last post by:
I am trying to send a 6 byte char array from the serial port in new C# 2005
Express:
com.Write(new string(new char { (char)34, (char)14, (char)192, (char)51,
(char)0, (char)0 }, 0, 6));
I am receiving 34,14,63,51,0,0 from the port as I connected Tx and Rx pins
to each other by using the following code:
private void com_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
|
by: davetelling |
last post by:
I'm a newbie that is still struggling with OOP concepts & how to make things
work they way I want. Using Visual C# Express, I have a form in which I added
a user control to display a graph, based upon data received via the serial
port. If I run the serial port in the main form code, I can get data and,
using public properties of the user control, transfer the data to be shown on
the graph. However, I am trying to add a feature that will...
|
by: pauland80 |
last post by:
Hello,
My soft passively listen to a device sending +- 300 bytes of data each
second. After several hours of work, the soft abruptly stops receiving
data without any error, (while the device sends properly, of course)
and I need to restart it (the python soft) to "reactivate" the ports.
I read that when the serial port encounters an error (frame error or
so, I imagine?) it stop receiving data until the library function...
| |
by: colin |
last post by:
Hi,
Im having a tiresome amount of trouble with using a bluetooth serial link.
The receiving end is a bluetooth-rs232 module conected to my embeded system.
The PC has a little usb bluetooth dongle, ive tried a another dongle with
widicom software
as I was having problems with the IVT bluesoleil software.
that seems to have got rid of some other problems,
|
by: max_mont |
last post by:
Hi all,
I'm a newbie in .NET technology.
I've already developed Serial communication applications in C++
(WIN32).
And I wanted to migrate to .NET technology.
There is a serial component in framework to read and write on serial
port.
I would like to make asynchronous reception. I saw that we can pass a
delegate to the serial class which is call when some data is readen on
the port.
|
by: JDS |
last post by:
I have an application that interfaces with a USB device using the .Net
serial port. The code works fine, displaying live data on the screen;
that is until the USB lead is pulled out from the PC when the program
hangs.
The obvious answer is not to pull the lead out, but unfortunately the
application is one in which there is a high possibility the lead will
be pulled out so the code needs to be more robust.
The form has a timer...
|
by: mayaanu |
last post by:
I have developed a GUI based application in C# for communicating with a 16 bit littleendian microcontroller device .the device has a serial port interface.
1.my appplication opens a COM port on which the device is connected with proper settings for the device.
2.It writes a command to the port.
3.datareceived event of the serial port reads the data in to a byte array.
3.i have closed the serialport using close() method
The problem that i...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |