Serving tiny webpage from microcontroller using RS232

Thread Starter

mike_canada

Joined Feb 21, 2020
239
I have a microcontroller setup as a web server to which my linux PC reacts strangely to.

Since the micro is AT89S52, I hook my board up to my PC's real serial port (not the USB to serial converter). Linux recognizes this port as /dev/ttyS0 I have the option of running the board at 9.6kbps and 57.6kbps so I try both speeds in all scenarios which I now describe.

The scenario that ALWAYS seems to work in both speed modes is this:
I open one terminal window and execute: cat /dev/ttyS0
I open the second window and execute: echo -en "GET / HTTP/1.1\x0D\x0A"
Then the first terminal responds with 100% correct data.

But when I use socat or netcat (nc) I often get corrupt data somewhere in the results. Usually at the beginning (see where the red arrows point in the attachment). I made sure to set the correct speed and to use raw mode with no echo before running each test. Sometimes at the 9.6K speed, I get a broken pipe error during data transmission.

Are socat and netcat bad utilities for the job? or are there system settings I need to change?

I just want to turn my microcontroller into a web server that can process web pages I built-into the microcontroller, not a bunch of garbage.

I also want to port this setup to a microsoft windows environment incase I need to quickly change my computer setup later. This is why I was interested in socat: because apparently parts of it work for windows.

Anyway, here's the results of my tests. The expected result is the first grey text above the yellow bar.

sample.png
 

ApacheKid

Joined Jan 12, 2015
1,609
I'm curious about the characters being printed, it seems they are always the same odd looking characters so that suggest there's no randomness or anything here.

The last five chars are ,,z-5 yet should be 00 OK

This might be a clue to what's going on...perhaps those utilities are trying to establish what character set is being used, is it ASCII, Unicode and so on...
 

atferrari

Joined Jan 6, 2004
4,768
Hi Mike,
Not sure I understand your application or why you are connecting to you microcontroller in that fashion, Have you thought of connecting via http by setting up your microcontroller with an ip address on your network?
Take a look at this link for more information on how to do this:
<deleted link>
I learn a lot on how to use a small mcu as a web server from this...
Why do I read "deleted link" ?
 
Top