This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Writing SSI Handler and passing it to web browser via SSI tag



Hello
I have created a SSI handler for specific tag, I just wana ask is this I have used is right or wrong to write SSI handler, please help


static int32_t SSIHandler(int32_t iIndex, char *pcInsert, int32_t iInsertLen) { // // Which SSI tag have we been passed? // switch(iIndex) { case SSI_INDEX_DATA: char buff[50]; pcInsert=&buff; buff={'0'}; iInsertLen=sizeof(buff); break; case SSI_INDEX_FORMVARS: break; case SSI_INDEX_SPEED: break; default: break; } return(strlen(pcInsert)); }

  • Ali, I am not sure if I understood what you intend to do, but I would avoid using pointers and would write something like this:

    static int32_t SSIHandler(int32_t iIndex, char *pcInsert, int32_t iInsertLen) {
        //
        // Which SSI tag have we been passed?
        //
        switch(iIndex)
        {
            case SSI_INDEX_DATA:
                pcInsert = {'0', '\0'}; // Shouldn't pcInsert hold a null-terminated string? '0' != '\0'
                                        // If you want an empty string you should use pcInsert = { '\0' };
                iInsertLen = sizeof(pcInsert); // What do you need here, the size of the string or the size of the pointer variable?
                                               // If you need the string length use strlen(pcInsert) or just iInsertLen = 1 
                                               // since it is a zero-ended string in this example holding just '0'
                break;
    
            case SSI_INDEX_FORMVARS:
                break;
    
            case SSI_INDEX_SPEED:
                break;
    
            default:
                break;
        }
        return iInsertLen;
    }

    Provide more information on what you intend to do so that we will be able to figure out the right solution.

    Angelo

  • Hello Angelo !

    Thanks for reply. I wana pass my adc output to SSI Handler will in turn requested by SSI tags, by the browser.
  • ALI HASSAN said:
    Hello Angelo !

    Thanks for reply. I wana pass my adc output to SSI Handler will in turn requested by SSI tags, by the browser.

    OK, this I understood, but I would like you to answer my comments in the code I proposed.

  • volatile uint32_t value;

    char pcInsert[50];



    void adc ();



    void main(void) {

    SysCtlMOSCConfigSet(SYSCTL_MOSC_HIGHFREQ);

    SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);



    adc();


    sprintf(pcInsert, "%9d", value);

    pcInsert[9] = '\0';



    // the remaining code in main() does not matter for our discussion

    }



    void adc() {

    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_4);

    ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);

    ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH9|ADC_CTL_IE|ADC_CTL_END);

    ADCSequenceEnable(ADC0_BASE, 3);

    while(1) {

    ADCIntClear(ADC0_BASE, 3);

    ADCProcessorTrigger(ADC0_BASE, 3);

    while(!ADCIntStatus(ADC0_BASE, 3, false));

    ADCSequenceDataGet(ADC0_BASE, 3, &value); // pass the address of the variable

    }

    }


    how can I use the pcInsert of above adc code to SSI Handler to display on web browser.


    Reagrds
  • Hi Ali, I am sorry, I haven't used SSI yet. I only have a Launchpad with no ethernet and no TCP IP library, I am not able to help you with that.

    Angelo