Here is the definition char readBuf[MAX_BUFFER_SIZE];
MAX_BUFFER_SIZE = 512 I think I may have just realized why this is occurring. When %s refers to readBuf it will output the value in the character array. But %x is outputting the address of it. Duh...not the first dumb mistake I've made today. On Tuesday, April 20, 2021 at 4:59:35 PM UTC-4 lazarman wrote: > Hello Walter > > I didn't see your definition of readBuf. > why you expecting an address to change? > I am glad you found the TI examples helpful. > > Mark > > > Sent from Yahoo Mail on Android > <https://go.onelink.me/107872968?pid=InProduct&c=Global_Internal_YGrowth_AndroidEmailSig__AndroidUsers&af_wl=ym&af_sub1=Internal&af_sub2=Global_YGrowth&af_sub3=EmailSignature> > > On Tue, Apr 20, 2021 at 12:33 PM, Walter Cromer > <[email protected]> wrote: > > I am using a Beaglebone Black and C to read analog inputs with PRU0 and > return the data to a host program using RPMSG. > > Basically, I read the data from FIFO0 fine, strip the step id from it and > copy it into an element of a character array in the PRU code. > > <start of snippet of PRU code> > > Data = HWREG(SOC_ADC_TSC_0_REGS + TSC_ADC_SS_FIFODATA(0)); > > if ((Data & 0x000F0000) == 0) { // checking the step id tag for step 0 > // if step == 0, strip off the step and put the data in array DetBSample > DetBSample[sampleno] = Data & 0xFFF; > > memcpy(payload, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 24); > // this came from TI's sample code, best I can tell it just preloads and > end of string character in the whole string. > ltoa((long)DetBSample[sampleno], payload); // put the value in > DetBSample[sampleno] in the character string payload > // now send the payload to the host > pru_rpmsg_send(&transport, dst, src, payload, 24); > > This code compiles and runs fine. > > On the host side, I do this when I'm kicked by the PRU. (This is a > snippet so brackets may not match!) > > /* Poll until we receive a message from the PRU and then print it */ > result = read(pollfds[0].fd, readBuf, MAX_BUFFER_SIZE); > if (result > 0) > { > Volts = atof(readBuf)*ADC_Res; > printf("Message %d received from PRU:%s or %x\n", i, > readBuf, readBuf); > printf("Volts read: %.3f\n",Volts); > > The output is strange though (snippet below). The message #, string > value of readBuf and Volts are all correct. But when I output readBug as > hex, it never changes. I thought it might be the address of readBuf but it > doesn't appear to be. > > The voltage matches the input we're providing from a bench power supply > and the decimal value is correct. It's just that this hex value doesn't > change. > > Message 97 received from PRU:3742 or 4b50b0 > Volts read: 1.644 > Message 98: Sent to PRU > Message 98 received from PRU:3744 or 4b50b0 > Volts read: 1.645 > Message 99: Sent to PRU > Message 99 received from PRU:3743 or 4b50b0 > Volts read: 1.645 > Received 100 messages, closing /dev/rpmsg_pru30 > > > -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to the Google Groups > "BeagleBoard" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/beagleboard/784129ee-1cf5-4438-881e-7ac6621e7aben%40googlegroups.com > > <https://groups.google.com/d/msgid/beagleboard/784129ee-1cf5-4438-881e-7ac6621e7aben%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/34361932-cafb-46a7-b31c-c962fe3bda89n%40googlegroups.com.
