![]() |
| | #1 |
| Registered User Join Date: May 2009
Posts: 2
| Insert Code: void get_weight_from_uart(char * weight)
{
FILE* fp;
char in_char = 0;
int pointer = 0;
fp = fopen ("/dev/RS232", "r+"); //Open file for reading and writing
if (fp ==0)
{
printf("error");
}
if (fp)
{
while (1)
{
in_char = fgetc(fp); // Get a character from the UART.
// if ((in_char == '\n') | (in_char == '\r') | (in_char == 0))
// {
// fclose (fp);
// return;
// }
// else
// {
weight[pointer++] = in_char;
printf("0%0x\n",weight);
delay(1000);
// }
}
fclose (fp);
}
// return 0;
}
05ffffa8 I am not sure whether or not I have the correct code written or why I am getting the same thing. Please advise. Thanks. Duffbuster |
| duffbuster220 is offline | |
| | #2 |
| Registered User Join Date: Oct 2008 Location: TX
Posts: 1,262
| The data read from the port maybe different each time but the code prints the location of weight over and over again, as in Code: printf("0%0x\n", weight);
|
| itCbitC is offline | |
| | #3 |
| Registered User Join Date: May 2009
Posts: 2
| Thanks for the quick response this is going to sound stupid because I am not very good with C but how do I print the values in weight? |
| duffbuster220 is offline | |
| | #4 |
| Registered User Join Date: Oct 2008 Location: TX
Posts: 1,262
| Code: printf("0%0x\n", weight[pointer-1]);
Last edited by itCbitC; 05-02-2009 at 01:24 PM. |
| itCbitC is offline | |
![]() |
| Tags |
| c code, embedded, rs232 |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| function trouble | rebel | C++ Programming | 4 | 12-21-2005 05:23 AM |
| Pick a number.... | Salem | A Brief History of Cprogramming.com | 39 | 01-19-2003 07:27 AM |
| Isn't the C Board a cool name? | DavidP | A Brief History of Cprogramming.com | 18 | 12-23-2002 01:09 PM |
| Considering shutting down the General Discussions board | webmaster | A Brief History of Cprogramming.com | 59 | 09-26-2002 08:41 PM |