Hi guys :)
I have a problem using serialcommunication.
I have a atmel 32A chip, I use to controll temperature and light in my home.
I wanna make a win software controlling the system.
Then I need to learn more of serialcommunication. Since I have several different input sensors and output signals, I need to send the address with the value I want to send with the serial print.
How could I do this?
In my living room, I need comfort. So I want to have 22īc. So I put in my compuret form 22īc.
Then the computer sends the data to the chip. The chip reads the data, and handles it as it should. The chip reads from sensor itīs 19īc, so it needs more heat. Then the chip sends 5v to a relay controlling the power to the electrical heater.
When its 22īc, the chip stops the relay.
How could I send the serial data?
I cant use HEX or BIN. I think i need to send in CHAR.
Why don't you send it as a text string?
String to int conversion is trivial enough to do at either end, but it sure makes for much easier testing (you can see exactly what you asked for).
For one thing, you can make sure everything works from just hyperterminal.
I have to agree:
If the problem is too tricky, make the problem easier. If you don't know how to send a char and you control BOTH sides of the communications, make the communications simpler. Hell, even SMTP starts off with a text HELO command when it could just specify "send a FFh-byte to initiate communication".
If you want to send byte-wise then, yes, you could use char as the storage (char is guaranteed to be only one byte wide). If you can get a file-pointer to the serial device (e.g. under Linux, /dev/ttyS0 or similar), then you can literally just open that for writing like a file and fputs() to it with a load of char's (be careful of using fprintf which might send out extraneous zero-bytes on the end of your string). If you can't get a file pointer to your serial device, I advise you to find a way to get one - and that's outside the scope of C and into the scope of "finding a suitable platform library".