Hello all..
I am quite new to C programming, but am having pretty good success so
far. I've written a short program to read from the serial port and
print the data to the screen, then quit. I'm starting simple!
My problem is that I only get the first line of data, up to the first
<cr>, then it quits. I'm sure this syntax isn't the best, so any
suggestions would be helpful. Here's how I'm doing it:
-------------------relavent code--------------
char sResult[4096];
fcntl(fd, F_SETFL, O_NDELAY);
read(fd, sResult, 200);
----------------------------------------------------
The messages that I read won't always be the same length, but should
always be less than 200. The output from the device looks like this:
P +
BNK +---------
CHN [ 1]
FRQ [ 856.3375]
CTC [ ]
With each line ending in a <cr>. When I compile and run all I get is:
P +
and nothing else. A dumb mistake, I'm sure. Any pointers/help
would be greatly appreciated. Thanks! 2 1606
Shawn wrote: Hello all..
I am quite new to C programming,
Off topic. THis group is for C++ programming.
-------------------relavent code--------------
char sResult[4096]; fcntl(fd, F_SETFL, O_NDELAY); read(fd, sResult, 200);
Off topic. fcntl() and read() are *nix-isms. Please consult
comp.unix.progr ammer.
----------------------------------------------------
The messages that I read won't always be the same length, but should always be less than 200. The output from the device looks like this:
P + BNK +--------- CHN [ 1] FRQ [ 856.3375] CTC [ ]
With each line ending in a <cr>. When I compile and run all I get is:
P +
Even if this was on topic, which it isn't, there is insufficient
information to answer your question. You have an error on line 42.
Shawn wrote: I am quite new to C programming,
....which is off-topic in comp.lang.c++, BTW...
but am having pretty good success so far. I've written a short program to read from the serial port and print the data to the screen, then quit. I'm starting simple!
Wow! Considering that C++ (and C as well) has no means to do what you
claim you have done, I am fairly impressed.
My problem is that I only get the first line of data, [...]
C++ FAQ 5.8.
V This thread has been closed and replies have been disabled. Please start a new discussion. 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...
|
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...
|
by: Mo |
last post by:
I am trying to set a text box value when data is received from the com
port (barcode reader). I am getting the following error when I try to
set the text box TXNumber after data is received
Cross-thread operation not valid: Control 'TXNumber' accessed from a
thread other than the thread it was created on.
Any ideas how to work around...
|
by: sherifffruitfly |
last post by:
Hi,
I have an xml file with structured like this:
<?xml version="1.0" encoding="UTF-8"?>
<Soldiers>
<Soldier name="Billy Smith" rank="Private" serial="34" />
(a bunch more soldiers)
|
by: Vivek Menon |
last post by:
Hi,
I am using a C program to write/read from a serial port. The writing
part is working perfectly fine. However, I am not able to read the
values correctly and display them. To debug this issue I am also seeing
the values on minicom. Now I have used fcntl() function and then read
refp = fcntl(fd, F_SETFL, 0);
res = read(fd,buf,1024); /*...
| |
by: RG |
last post by:
I am trying to read from my serial port a 24 bit binary number.
I was able to read this number as a HEX but I was getting errors as at
times using the vBCrLf indicator.
I also can read it as an incoming string looking for the vbCrLf
indicator but it too gave me errors as the length of the stream was
not always 24 bits for some reason.
I...
|
by: John Wright |
last post by:
I am trying to read the data from a device on a serial port. I connect just
fine and can receive data fine in text mode but not in binary mode.
In text mode the data from the device comes in like this:
S~5BBBBBBBBBBBBBBB5BBBBBBBB5B31BB4BB2B5BB4BBBE
S is the start of the line, ~ indicates a good read, B is a blank reading,
and the...
|
by: cmdolcet69 |
last post by:
The sub below reads the value of position from my serial write
command. However i need to read only the (3) and (4) index of the byte
array and then need to convert it into a integer. When i get to the
step invalue = bitconverter.toint32(Newpacket,0) line i trigger an
error saying that the byte array is less than the read byte array.
How can...
|
by: Hal Vaughan |
last post by:
I've done a fair amount of Googling for information on reading the serial
port in C++ (and in Linux). Unfortunately, out of every 4 hits, 1 seems to
be an unanswered question, 1 is someone saying, "That's easy, there's a lot
out there, Google it,", 1 is a discussion on it without examples and the
other is who knows what.
I did find some...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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. ...
| |
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...
|
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...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
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...
| |