Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Read data from hyperterminal in C (ASCII to INTEGER)

Status
Not open for further replies.

hemanthjv

Newbie level 4
Newbie level 4
Joined
Apr 24, 2013
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,322
Hi

I need a help to develop a C code to read data from terminal in order to convert ascii to number. Do you know or where to find the information or any suggestion?
The terminal should accept a input from the user (Example : new temperature value) and convert into integer. This integer value will be transferred across the interface (RS232 interface) to the memory.

example : the message structure -
struct memoryTag1;
typedef struct memoryTag1{
char a[10]= {'+','0','2','6','.','5','E','A','\r'}; // first five bits is the new temperature value (+26.5), two bits (euipment name- EA), carriage reurn.
char b[10]= {'-','0','2','4','.','5','E','B','\r'};
char c[8]= {'+','0','2','0','E','C','\r'};
}Memory1;

thank you in advance.
 

a[2]=a[2]-48;
a[3]=a[3]-48;
a[4]=a[4]-48;
a[6]=a[6]-48;
float value = a[4]*100+a[3]*10+a[2]+a[6]/10;

if you want to convert into int than discard a[6]/10?
 

how user will give the input in the terminal. could you help me w.r.t code ??
 

write character and press enter simply or if you want to see yuor character go to properties , ascii settings and enable echo character mode .
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top