Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jharvey

Pages: [1]
1
µTasker general / Re: Different UARTs for send and recieve
« on: April 28, 2008, 02:49:13 PM »
Thanks for the reply Mark, that is what I figured....

I've done the following:
1) Made global variables for the interface parameters:
Code: [Select]
TTYTABLE tInterfaceParametersIn;
TTYTABLE tInterfaceParametersOut;

2) Modified fnSetNewSerialMode to set up the appropriate channel based on the additional param:
Code: [Select]
#ifdef SERIAL_INTERFACE
// After changes, we set up the new serial configuration
//
extern QUEUE_HANDLE fnSetNewSerialMode(unsigned char ucDriverMode, unsigned int uiUartChannel)
{
    //TTYTABLE tInterfaceParameters;                                       // table for passing information to driver
    //Jesse //tInterfaceParameters.Channel = DEMO_UART;                            // set UART channel for serial use
    if(uiUartChannel == 1)
    { 
    tInterfaceParametersIn.Channel = uiUartChannel;                            // set UART channel for serial use
    tInterfaceParametersIn.ucSpeed = temp_pars->temp_parameters.ucSerialSpeed; // baud rate
    tInterfaceParametersIn.Rx_tx_sizes.RxQueueSize = RX_BUFFER_SIZE;       // input buffer size
    tInterfaceParametersIn.Rx_tx_sizes.TxQueueSize = TX_BUFFER_SIZE;       // output buffer size
    tInterfaceParametersIn.Task_to_wake = OWN_TASK;                        // wake self when messages have been received
    #ifdef SUPPORT_FLOW_HIGH_LOW
    tInterfaceParametersIn.ucFlowHighWater = temp_pars->temp_parameters.ucFlowHigh;// set the flow control high and low water levels in %
    tInterfaceParametersIn.ucFlowLowWater = temp_pars->temp_parameters.ucFlowLow;
    #endif
    tInterfaceParametersIn.usConfig = temp_pars->temp_parameters.usSerialMode;
    #ifdef TEST_MSG_MODE
        tInterfaceParametersIn.usConfig |= (MSG_MODE);
        #if defined (TEST_MSG_CNT_MODE) && defined (SUPPORT_MSG_CNT)
            tInterfaceParametersIn.usConfig |= (MSG_MODE_RX_CNT);
        #endif
        tInterfaceParametersIn.usConfig &= ~USE_XON_OFF;
        tInterfaceParametersIn.ucMessageTerminator = '\r';
    #endif
    #ifdef SERIAL_SUPPORT_DMA
        tInterfaceParametersIn.ucDMAConfig = UART_TX_DMA;                  // activate DMA on transmission
    #endif

    if (SerialPortIDIn = fnOpen( TYPE_TTY, ucDriverMode, &tInterfaceParametersIn )) { // open or change the channel with defined configurations (initially inactive)
        fnDriver( SerialPortIDIn, ( RX_ON ), 0 );                  // enable rx and tx
    }
    return SerialPortIDIn;
    }
    else if( uiUartChannel == 0 )
    {
    tInterfaceParametersOut.Channel = uiUartChannel;                            // set UART channel for serial use
    tInterfaceParametersOut.ucSpeed = temp_pars->temp_parameters.ucSerialSpeed; // baud rate
    tInterfaceParametersOut.Rx_tx_sizes.RxQueueSize = RX_BUFFER_SIZE;       // input buffer size
    tInterfaceParametersOut.Rx_tx_sizes.TxQueueSize = TX_BUFFER_SIZE;       // output buffer size
    tInterfaceParametersOut.Task_to_wake = OWN_TASK;                        // wake self when messages have been received
    #ifdef SUPPORT_FLOW_HIGH_LOW
    tInterfaceParametersOut.ucFlowHighWater = temp_pars->temp_parameters.ucFlowHigh;// set the flow control high and low water levels in %
    tInterfaceParametersOut.ucFlowLowWater = temp_pars->temp_parameters.ucFlowLow;
    #endif
    tInterfaceParametersOut.usConfig = temp_pars->temp_parameters.usSerialMode;
    #ifdef TEST_MSG_MODE
        tInterfaceParametersOut.usConfig |= (MSG_MODE);
        #if defined (TEST_MSG_CNT_MODE) && defined (SUPPORT_MSG_CNT)
            tInterfaceParametersOut.usConfig |= (MSG_MODE_RX_CNT);
        #endif
        tInterfaceParametersOut.usConfig &= ~USE_XON_OFF;
        tInterfaceParametersOut.ucMessageTerminator = '\r';
    #endif
    #ifdef SERIAL_SUPPORT_DMA
        tInterfaceParametersOut.ucDMAConfig = UART_TX_DMA;                  // activate DMA on transmission
    #endif

    if (SerialPortIDOut = fnOpen( TYPE_TTY, ucDriverMode, &tInterfaceParametersOut )) { // open or change the channel with defined configurations (initially inactive)
        fnDriver( SerialPortIDOut, ( TX_ON ), 0 );                  // enable rx and tx
    }
    return SerialPortIDOut;
    }
}
#endif

It may not be the cleanest approach, but it's working for me....

2
µTasker general / Different UARTs for send and recieve
« on: April 27, 2008, 06:48:06 PM »
Hey Mark,
I've checked through the documentation but haven't been able to find the answer to whether or not there is an easy way to use a different UART channel for sending and receiving.

With the default implementation, it looks like both use the SerialPortID which gets set to DEMO_UART in fnSetNewSerialMode.

It looks as if I will have to create a new SerialPortID using a different channel, that way I will have one for input and one for output.

Then I will have to replace all references to SerialPortID that are used in reads with SerialPortIDIn and all that are used in outs with SerialPortIDOut.

Is there an easier way to do this?

Thanks,
Jesse

3
I appreciate the sample code BitCoder!  I just wanted to follow up and list exactly how I used your information with the M52235evb project.  Look for the two sets of // Begin New Code and // End New Code comments.\

I basically have an array of characters stored.  The array was created with a size of 500 and all elements were set to 0 to start:
Code: [Select]
extern char ucLastHB[500] = {0};

The following basically inserts all elements from index 0 to the first 0 valued element.

1) In http.c:
Code: [Select]
// Begin New Code
// Create an XML document
int MakeXmlDocument(char* query)
{
unsigned int len;

fnDebugMsg("In MakeXmlDocument, Sending Data\r\n");

// Write to tcpBuffer here, return the number of bytes written.
len = uStrlen("<value>");
len += uStrlen(ucLastHB0);
len += uStrlen("</value>");

uMemcpy(&(HTTP_Tx->ucTCP_Message[0]), "<value>", uStrlen("<value>"));
uMemcpy(&(HTTP_Tx->ucTCP_Message[uStrlen("<value>")]), ucLastHB0, uStrlen(ucLastHB0));
uMemcpy(&(HTTP_Tx->ucTCP_Message[uStrlen("<value>") + uStrlen(ucLastHB0)]), "</value>", uStrlen("</value>"));

return len;
}
// End New Code

// Display a specific web page
//
static int fnDoWebPage(CHAR *cFileName, HTTP *HTTP_session)
{
    unsigned short usLen = HTTP_BUFFER_LENGTH;
    unsigned char ucPush = TCP_FLAG_PUSH;
    unsigned char *ucFile;
#ifdef WEB_WINDOWING_BUFFERS
    int iRtn = 0;
    unsigned short usNext = 0;
#endif

#ifdef SUPPORT_INTERNAL_HTML_FILES
   
// Begin New Code
if ( (cFileName != 0) && (!uMemcmp(cFileName, "XML?", 4)))
{
    int len = MakeXmlDocument(cFileName + 4);
    HTTP_session->ucState = HTTP_STATE_ACTIVE;
    HTTP_session->usUnacked = len;
    uiDataReady = 0;  // Only needed for my application
    return fnSendTCP(HTTP_session->OwnerTCPSocket, (unsigned char*)&HTTP_Tx->tTCP_Header, len, 0) > 0;
}
    // End New Code
    else if (cFileName != 0) {                                                // predefined internal file is to be displayed
#endif
        if ((HTTP_session->ucState > HTTP_STATE_ACTIVE) || (*cFileName < '0')) { // if we have just authenticated, always do start page
            *cFileName = '0';                                            // default start side
        }
        ucFile = uOpenFile(cFileName);                                   // open the file to be displayed
        HTTP_session->ucState = HTTP_STATE_ACTIVE;

And in my HTML page I have:
Code: [Select]
//////////////////////////////////////////////////////////////////////////////////////
// Request input file
//////////////////////////////////////////////////////////////////////////////////////
function makeRequest(url)
{
var http_request = false;

    if (window.XMLHttpRequest)
{
// Mozilla, Safari,...
alert('XMLHttpRequest');
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType)
{
        http_request.overrideMimeType('text/xml');
        }
    }
else if (window.ActiveXObject)
{ // IE
  try
{
alert('In Microsoft.XMLHTTP');
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
        }
catch (e)
{
            try
{
alert('Msxml2.XMLHTTP');
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
            }
catch (e)
{
alert('In catch case...bad');
}
        }
    }

    if (!http_request)
{
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }

    http_request.onreadystatechange = function() { alertContents(http_request); };
    http_request.open("GET", url, true);
    http_request.send("");
}

//////////////////////////////////////////////////////////////////////////////////////
// Infinite loop with delay
//////////////////////////////////////////////////////////////////////////////////////
function loop()
{
alert( 'Calling makeRequest' );
makeRequest("XML?HBValue");
//setTimeout("loop()",1000);
//setTimeout("loop()",10);
}

So it's pretty much exactly what BitCoder said, just figured another example couldn't hurt...

Thanks for all the help guys.


edit: I noticed that I was not returning valid XML because I was not adding the <value></value> tags on.  I've updated the MakeXmlDocument function above.

4
NXPTM M522XX, KINETIS and i.MX RT / Re: Not getting LINK LED
« on: April 24, 2008, 10:44:05 PM »
Also, I tried pinging a machine on the same subnet and it fails on ARP resolution.

Quote
ARP resolution started

#
ARP resolution failed

I read the DHCP pdf and did not see anything that could point to my problem in there.


5
NXPTM M522XX, KINETIS and i.MX RT / Not getting LINK LED
« on: April 24, 2008, 10:37:50 PM »
Hey Mark,
I want to thank you for all the help you have provided so far.  The progress we've made would not have been possible without you.

We have everything functioning when our M52235evb is connected directly to a laptop using a crossover cable.

However, we need to put the device on our academic network.  I have talked with ITS and they assign an IP address to a MAC address.

To ensure that we do not conflict with any other MAC addresses on campus, we used an address that started with FF:.....

I've updated the IP configuration variables in application.c including the MAC, IP, Net Mask, Gateway and DNS servers to match with the network I will be plugging into.

I verified that USE_DHCP and USE_UDP are defined in config.h.  I also tried running with the ACTIVE_DHCP commented out and uncommented with no change in results.

However, I do not get a LINK light when I plug the M52235evb into our network and reset the board.

The settings look fine in the "Configure LAN interface" menu after doing a 'show_config':
Quote
IP address = 129.CORRECT
MAC address = ff-CORRECT
Subnet mask = 255.255.255.0
Default gateway = 129.CORRECT
LAN speed AUTO
DHCP_SERVER - enabled
* Correct used to replace some of the digits but represent that the values are as expected.

One thing I noticed is that the ARP table is empty.  Should it at least contain the DHCP server?
Quote
arp -a
ARP Table contents:
End

I've tried disabling DHCP_SERVER and the same results were seen.

I do not really think I can run WireShark on the network.

This may be a problem with the registration from ITS but I just wanted to see if there is anything you can think could be the problem.

Thank you.
-Jesse

6
Thanks for the information Mark.

What I ended up doing is creating a file called XML as the user above suggested.  In it I placed:
Code: [Select]
<value>£vH0</value>
I then added a case for 'H' to the fnInsertString function in webInterface.c:
Code: [Select]
case 'e':
  #ifdef USE_SMTP
            cPtr = (unsigned char *)fnDebugDec(usSentEmails, 0, cValue);
            *usLengthToSend = ((CHAR *)cPtr - cValue);
  #else
            cValue[0] = '0';
            *usLengthToSend = 1;
  #endif
            break;
           
        case 'H':
            cPtr = (unsigned char *)fnDebugDec(ucLastHB, 0, cValue);
            *usLengthToSend = ((CHAR *)cPtr - cValue);
            break;

        default:
            *usLengthToSend = 0;
            return 0;
        }

I made ucLastHB a static unsigned char towards the top of config.h so that I could modify it in application.c and read it in webInterface.c:
Code: [Select]
static unsigned char ucLastHB;
I set this variable in application.c:
Code: [Select]
if ((iAppState & (STATE_ACTIVE | STATE_DELAYING | STATE_ESCAPING | STATE_RESTARTING | STATE_VALIDATING)) && (Length = fnMsgs(SerialPortID))) {
            while (Length = fnRead( SerialPortID, ucInputMessage, MEDIUM_MESSAGE)) {
           
            // This gets printed any time a character is recieved.  Should be able to just tie in here.
            ucLastHB = ucInputMessage[0];

            fnEchoInput(ucInputMessage, Length);         

If I replace the 'ucLastHB' in the 'H' case above with a hard coded value (127), that value will be returned to me just fine by the XML file (The response is <value>127</value>).  However, if I leave it as ucLastHB, all I get is 0 (<value>0</value>).

Does anyone see something I could be doing wrong that would cause this behavior?

Thank you,
-Jesse

7
Thanks for all of your help so far Mark.

I've been following the instructions in this thread along with the Coldfire AJAX demo and now have a webpage that can read a file and post the value needed.

However, I am unsure how to dynamically create the file when I get a character over the uart. 

I see that the code in application.c below gets called everytime a character is recieved over UART, would this be an acceptable place to make the call to write the file?
Code: [Select]
         -snip-
         if ((iAppState & (STATE_ACTIVE | STATE_DELAYING | STATE_ESCAPING | STATE_RESTARTING | STATE_VALIDATING)) && (Length = fnMsgs(SerialPortID))) {
            while (Length = fnRead( SerialPortID, ucInputMessage, MEDIUM_MESSAGE)) {
           
            // This gets printed any time a character is recieved.  Should be able to just tie in here.
            static const CHAR ucJ_TEST[] = "Testing to see where this gets done\r\n";
            fnWrite(SerialPortID, (unsigned char *)ucJ_TEST, sizeof(ucJ_TEST));
           
                fnEchoInput(ucInputMessage, Length);
               
                // Insert code to save character to file             
                -snip-

Also, when working with the coldfire, I was able to just create a static file and put in it "~14D".  This would cause it to return the value of html_vars[14] in decimal format.  Is there anything like that supported with uTasker?  I see the Stats page uses things such as "£vsf", is this doing the same thing?  How do I go about mapping a variable to a value?

Either of these solutions will work for me.

I'd appreciate any assistance you could offer.

Thanks,
-Jesse

Pages: [1]