Author Topic: Ethernet to rs-232  (Read 16078 times)

cuma31

  • Newbie
  • *
  • Posts: 2
    • View Profile
Ethernet to rs-232
« on: March 26, 2006, 07:58:26 PM »
I am using the SBC65EC board and I have been trying to simply take a value from a webpage I have downloaded to the webserver and output that value via rs-232 cable.  So far I have not been able to modify the source code properly to accomplish this.

If anyone can help me out or send me an example showing how they integrated a similar application in the main mxwebsrvr code originally programmed on the PIC I would greatly appreciate it.

Thanks

modtro2

  • Administrator
  • Hero Member
  • *****
  • Posts: 564
    • View Profile
Re: Ethernet to rs-232
« Reply #1 on: March 27, 2006, 04:37:09 PM »
G'Day

Could you maybe include a screen shot or some source code of your webpage you have downloaded to the SBC65EC? Do you have a text field with a submit button, and you want the contents of the text field sent via RS232 when submitted, or something similar? I can assist you if you give me some more specific information.

Modtronix Admin

cuma31

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Ethernet to rs-232
« Reply #2 on: March 27, 2006, 08:15:13 PM »
This is the code I am implementing in the javascript to create my webpage (I have called this function in temp1.cgi)

function tcfg(temp1) {
   <br> \
   <form method=GET action=\"TEMP1.CGI\"> \
   <table> \
      <tr> \
         <td width=150> Desired Temperature:</td> \
         <td><select name=k47 id=selectTemp size=1> \
            <option value=0>10</option> \
            <option value=1>11</option> \
            <option value=2>12</option> \
            <option value=3>13</option> \
            <option value=4>14</option> \
            <option value=5>15</option> \
            <option value=6>16</option> \
            <option value=7>17</option> \
            <option value=8>18</option> \
            <option value=9>19</option> \
            <option value=10>20</option> \
            <option value=11>21</option> \
            <option value=12>22</option> \
            <option value=13>23</option> \
            <option value=14>24</option> \
            <option value=15>25</option> \
            <option value=16>26</option> \
            <option value=17>27</option> \
            <option value=18>28</option> \
            <option value=19>29</option> \
            <option value=20>30</option> \
            <option value=21>31</option> \
            <option value=22>32</option> \
            <option value=23>33</option> \
            <option value=24>34</option> \
            <option value=25>35</option> \
            <option value=26>36</option> \
            <option value=27>37</option> \
            <option value=28>38</option> \
            <option value=29>39</option> \
            <option value=30>40</option> \
            </select> \
         </td> \
      </tr> \
   </table> \
   <br> \
   <hr> \
   <table> \
      <tr><td width=20></td><td><input type=submit value=Submit></td> \
   </table> \
   </form>");

   /* Select Desired Temperature */
   var x=document.getElementById("selectTemp");
   x.selectedIndex = temp1;
}

I have added the following line to the appcfg.h file (hopefully this is correct)

   APPCFG_TEMPERATURE            ///< Offset = 71 = 0x47

Now I want to take whatever value is submitted from the pulldown menu on my webpage and send that value out via rs-232 to another microcontroller when submitted.  I think there is a function called serPutByte () that I can use but I am not sure.

Thank you for your assistance

128bit

  • Hero Member
  • *****
  • Posts: 70
    • View Profile
Re: Ethernet to rs-232
« Reply #3 on: May 02, 2006, 08:29:13 AM »
Hi,

The code for this is fairly simple.

To handle the web input you too make an addition to two files.

Firstly add this to the httpexec.h file: Any where in the file will do.

//Temp Command Variable.
#define CMDGROUP_Temp ('z') // Note z is the first letter of the variable name in your webpage.

Next in httpexec.c file Right before this line
    /////////////////////////////////////////////////
    //We received a general command with value
    else if (name[0] == CMDGROUP_GENERAL)


Add the following code.

   else if (name[0] == CMDGROUP_Temp)
   {
                  serPutString((BYTE*) value); // Send value via RS232
        }


At the top of the same file add this with the other include files.

#include "serint.h" // Include serial routines.


Finally in your html you need to change the variable name to z so change
<select name=k47 id=selectTemp size=1>

with

<select name=z id=selectTemp size=1>

I hope this helps

This code will send the value by RS232 when the form is submitted.

You only need to add   APPCFG_TEMPERATURE            ///< Offset = 71 = 0x47
if you want the temp to be stored in eeprom and used for something later. So for just sending the value when the page is submitted you will not need this.

Best of Luck

Daniel.
----------------------------------------------------
There are 10 types of people, those who understand Binary and those who don't! :)

McSteve

  • Full Member
  • ***
  • Posts: 11
    • View Profile
Re: Ethernet to rs-232
« Reply #4 on: May 11, 2006, 01:36:35 PM »
WOW - that was great (I actually got it to work).

But now the big question: can something (hopefully on the same level of complexity or less) be used in the other direction?
That is, can string be sent to the RS232 port and then show up in the webpage?

Please, please, please.

Cheers-
 :|

128bit

  • Hero Member
  • *****
  • Posts: 70
    • View Profile
Re: Ethernet to rs-232
« Reply #5 on: May 11, 2006, 08:59:55 PM »
Yep sure that wont be hard at all, but I need to know a few details about the specifics.

First of How much data are we talking about?
Do you need to to display all data eg Logging or just the last sequence or transmision.

Do you already have any code that deals with the incoming RS232 (eg so I can just modify it, other wise I'll create a new routine).

Get back to me with these details and I'll see what I can do.

Thanks

daniel.
----------------------------------------------------
There are 10 types of people, those who understand Binary and those who don't! :)

McSteve

  • Full Member
  • ***
  • Posts: 11
    • View Profile
Re: Ethernet to rs-232
« Reply #6 on: May 19, 2006, 11:04:04 AM »
128bit, thanks for the reply and the offer to help.  It would be fantastic if you could solve this last bit of the puzzle.
I have an RS-232 input that varies in length from 1 to about 25 characters and terminates with the CR LF (carriage return line feed) characters.
It is not logged, I can just query the device and ask for the lastest reading.  It is at 9600 baud.  I just need to get the string into the webpage so I can play with it in JavaScript.  If it could be handled in a similar fashion as the I/O port bits that would be great, but getting it into the webpage in any form would be a real advancement for my project.

Many, many thanks-

McSteve
 :-)

128bit

  • Hero Member
  • *****
  • Posts: 70
    • View Profile
Re: Ethernet to rs-232
« Reply #7 on: May 23, 2006, 12:29:04 AM »
Hi,

I will write the solution in the next couple of days, I am a little busy at the moment with exams and such. So sorry for the delay.

Thanks

Daniel.
----------------------------------------------------
There are 10 types of people, those who understand Binary and those who don't! :)

McSteve

  • Full Member
  • ***
  • Posts: 11
    • View Profile
Re: Ethernet to rs-232
« Reply #8 on: May 23, 2006, 08:53:03 AM »
No problem.  I understand the exam thing, even though that was 25 years ago the memories still haunt me.  Speaking of all that time in the past could I request that the write-up of any solution be as simple as possible to aid in my limited understanding of this topic.  Your solution for sending rs-232 signals out of the SBC65 challenged my technical abilities (but I did it!).  Its been a long time since I studied microprocessors and assemblers and linkers and loaders and all that stuff.  Wow, how things have changed since my Motorola 6800 and Intel 8080 school days.  Although it is more difficult these days (or is that just my age showing) it is still fun.

Good Luck with the exams !!!

Cheers-
McSteve
 :wink:

McSteve

  • Full Member
  • ***
  • Posts: 11
    • View Profile
Re: Ethernet to rs-232
« Reply #9 on: June 06, 2006, 08:37:24 AM »
Hi,

its been a couple of weels since my last posting.  Have you had any luck with your exams or the new code for the RS-232 problem?

Cheers-
McSteve
 :?

128bit

  • Hero Member
  • *****
  • Posts: 70
    • View Profile
Re: Ethernet to rs-232
« Reply #10 on: June 06, 2006, 09:31:49 PM »
Hi,

I'm sorry are you able to wait 2.5 more weeks. I am really sorry about the delay, but I promise it will be top of the list as soon as I finish my last exam. My last exam is on the 22nd.

Sorry about the delay.

Daniel.
----------------------------------------------------
There are 10 types of people, those who understand Binary and those who don't! :)

128bit

  • Hero Member
  • *****
  • Posts: 70
    • View Profile
Re: Ethernet to rs-232
« Reply #11 on: June 24, 2006, 08:02:30 AM »
Hi,

Sorry once again for the delay... Do you still need the code, if so reply to this and I will post as soon as possible.

THanks

Daniel.
----------------------------------------------------
There are 10 types of people, those who understand Binary and those who don't! :)

McSteve

  • Full Member
  • ***
  • Posts: 11
    • View Profile
Re: Ethernet to rs-232
« Reply #12 on: June 27, 2006, 06:37:53 AM »
 :-o
Yes.  The requirement and timing has gone from critical to desperate.  To recap:  I have a digital compass.  I outputs a 9600-baud data string of about 25 characters, ending with CR/LF.  It does this continually, several times a second.  I do NOT need a constant record.  I am only interested in a line of data at or near the time I ask for it.  I need the data to show up in a web page.  (As my skill level is not too advanced) - I would like to be able to handle these data much like inputting bits from ports, that is, similar to using %f07 to read bit 7 of port f.  I can handle a bit of Javascript if necessary.

Thank you-

McSteve

128bit

  • Hero Member
  • *****
  • Posts: 70
    • View Profile
Re: Ethernet to rs-232
« Reply #13 on: June 27, 2006, 09:31:11 PM »
Hi,

Ok sorry for the delay, I am writting the code at the moment. I'm going to double buffer the data, that way it will always be available.

Sorry Again,

Daniel
----------------------------------------------------
There are 10 types of people, those who understand Binary and those who don't! :)

128bit

  • Hero Member
  • *****
  • Posts: 70
    • View Profile
Re: Ethernet to rs-232
« Reply #14 on: June 28, 2006, 12:10:54 AM »
Hi,

One new question, are you transmitting anything on the serial port, or just recieving?

Thanks

Daniell
----------------------------------------------------
There are 10 types of people, those who understand Binary and those who don't! :)