ExampleConsole_C_WORK_ExampleC++_DoesNotWork

Post your C and C++ discussions here
Post Reply
disavmic
Newbie
Posts: 0
Joined: Wed Dec 15, 2021 12:57 pm

ExampleConsole_C_WORK_ExampleC++_DoesNotWork

Post by disavmic »

:!: Hi,
I have problems to run pl1000 SDK routine(s) implemented in C++ Borland code.
Execution under C Borland, instead, works nice.
Code much similar that of routine "void collect_windowed_blocks (void)",-line397-, in "pl1000Con.c" SDK Pico example with:
A)two little adds,
B)/*WathList_{1|2|3} inserted for variables: status=... ; g_handle=... ; channels[]=... ; nChannels=....
in execution points:

Code: Select all

  int16_t		g_handle;
  int16_t		isReady;
  PICO_STATUS status;

  status = pl1000OpenUnit(&g_handle);

	int16_t		channels [] = {(int16_t) PL1000_CHANNEL_1, (int16_t) PL1000_CHANNEL_2 };
	uint32_t	nSamples = 1000; // Should be equal to nChannels * nSamplesPerChannel
	int16_t		nChannels = 2;

/*WatchList_1: status=0 ; g_handle=16384 ; channels[]={1,2} ; nChannels=2 */

	uint32_t	nSamplesPerChannel = 500;
	uint32_t	nSamplesCollected;

  uint16_t* samples = (uint16_t*) calloc(nSamples, sizeof(uint16_t));	// Size of array should be equal to nChannels * nSamplesPerChannel

	uint32_t	usForBlock = 1000000;	// 1s
	uint16_t 	overflow = 0;
	uint32_t	triggerIndex = 0;
	uint32_t	samplingIntervalUs = 0;

	// Set the trigger (disabled)
	status = pl1000SetTrigger(g_handle, FALSE, 0, 0, 0, 0, 0, 0, 0);

/*WatchList_2: status=0 ; g_handle=16384 ; channels[]={1,2} ; nChannels=2 */

	// Set sampling rate and channels
	status = pl1000SetInterval(g_handle, &usForBlock, nSamplesPerChannel, channels, nChannels);

/*WatchList_3: status=16="PICO_NULL_PARAMETER" ; g_handle=16384 ; channels[]={2,51} ; nChannels=0 */

	samplingIntervalUs = (usForBlock / (nSamplesPerChannel * nChannels));

	// Run
	status = pl1000Run(g_handle, nSamplesPerChannel, BM_SINGLE);

	// Wait until unit is ready
	isReady = 0;

	while(isReady == 0){
		status = pl1000Ready(g_handle, &isReady);
	}

	nSamplesCollected = nSamplesPerChannel;

	status = pl1000GetValues(g_handle, samples, &nSamplesCollected, &overflow, &triggerIndex);

	status = pl1000Stop(g_handle);

  /* free memory */
  free(samples);
As you may see at
:?: /*WatchList_3: status=16="PICO_NULL_PARAMETER" ; g_handle=16384 ; channels[]={2,51} ; nChannels=0 */
after call pl1000SetInterval() function, the array channel[] change in elements and dimension.
Obviously these variables assume random value between more launch program.
:!: Furthermore, the return status of pl1000SetInterval() function assumes error code 16 (0x) with "PICO_NULL_PARAMETER" meaning.

Qual è il pasticcio?
Qualcuno mi aiuti, per favore.

Grazie,
Michele.

disavmic
Newbie
Posts: 0
Joined: Wed Dec 15, 2021 12:57 pm

Re: ExampleConsole_C_WORK_ExampleC++_DoesNotWork

Post by disavmic »

Solved, thanks anyway!
Greetings, Michele.

Post Reply