NvSciBufObjGetPixels returns NvSciError_BadParameter

Please provide the following info (tick the boxes after creating this topic):
Software Version
DRIVE OS 6.0.10.0
DRIVE OS 6.0.8.1
DRIVE OS 6.0.6
DRIVE OS 6.0.5
DRIVE OS 6.0.4 (rev. 1)
DRIVE OS 6.0.4 SDK
other

Target Operating System
Linux
QNX
other

Hardware Platform
DRIVE AGX Orin Developer Kit (940-63710-0010-300)
DRIVE AGX Orin Developer Kit (940-63710-0010-200)
DRIVE AGX Orin Developer Kit (940-63710-0010-100)
DRIVE AGX Orin Developer Kit (940-63710-0010-D00)
DRIVE AGX Orin Developer Kit (940-63710-0010-C00)
DRIVE AGX Orin Developer Kit (not sure its number)
other

SDK Manager Version
2.1.0
other

Host Machine Version
native Ubuntu Linux 20.04 Host installed with SDK Manager
native Ubuntu Linux 20.04 Host installed with DRIVE OS Docker Containers
native Ubuntu Linux 18.04 Host installed with DRIVE OS Docker Containers
other

Issue Description

Hello,
I’m working for the application for conveying camera image data through ROS, and I modified samples/nvmedia/nvsipl/test/camera/CNvSIPLConsumer.hpp to see the feasibility of copying an image data from the NvSciBufObj.
(I used to use NvMediaImageGetBitsin DRIVE OS 5.2.6.0 and need similar function)

What I did on the file is, just inserting some functions into OnFrameAvailable funciton since I found that WriteBufferToFilein CFileWriter.hpp has the flow I wanted to have.
I added the code based on the CFileWriter.hpplike the flow below. (I am sharing the simplified code herewith just to show the flow)

NvSciBufObj buffer = pNvMBuffer->GetNvSciBufImage();
SIPLStatus status = PopulateBufAttr(buffer, rawBufAttrs);
status = GetBuffParams(rawBufAttrs, &xScalePtr, &yScalePtr, &bytesPerPixelPtr,&numSurfaces,&isPackedYUV);
NvSciError sciErr = NvSciBufObjGetPixels(buffer, NULL, (void **)pBuff, size, pBuffPitches);

and then updated size, pBuffPitches, pBuff based on the code in CFileWriter.hpp

After the code modification, I confirmed that the inserted code is working by print the related values out like,

size = 1048576, planeCount = 2, width [960][480], height [540][270], pitch [1024][1024], bpp [8][16]
height = 540, yScalePtr[0] = 1.00, pBuffPitches[0] = 960, size[0] = 518400, imageSize 518400,
__________ pBuff[0] = 0xffff4817ca50, buffIter = 0xffff481fb350

But the return value of NvSciBufObjGetPixels is 256 which represents BadParameter.

I checked the error cases in [NVIDIA DRIVE OS Linux SDK API Reference: NvSciBuf Object APIs | NVIDIA Docs](https://API reference) but couldn’t find the root cause.

Can you please help me out for this issue?

Does that mean, none of the cases listed there is related to your issue. Could you check if you see any error/messages/hints in /var/log/syslog after running the application.

Hello @SivaRamaKrishnaNV
I attached the snippet herewith. (copied the part of log which added after running the application)
syslog_nvsipl_application_Sep04.log (54.7 KB)

Hi @SivaRamaKrishnaNV, can you please follow up this ticket ?

I notice below error in the logs.
User shall request CPU access via NvSciBufGeneralAttrKey_NeedCpuAccess before calling NvSciBufObjGetPixels . Without CPU access, NvSciBuf cannot copy the buffer from source to destination using CPU copy

Could you check the what are the attributes set in NvBuf? Please check if setting NvSciBufGeneralAttrKey_NeedCpuAccess helps?

Hi @SivaRamaKrishnaNV,
I have refered to CFileWriter.hpp and CUtils.cpp to see the use case of NvSciBufObjGetPixels and
modified the CNvSIPLConsumer.hpp to use it.
I attach the modified CNvSIPLConsumer.hpp named by CNvSIPLConsumer_user.hpp
Please see(compare) and give a guideline to apply NvSciBufGeneralAttrKey_NeedCpuAccess.
Just for your information, I’m working on deliverying image data to host node through the similar implementation in CFileWriter.hpp.

CNvSIPLConsumer_original.hpp.txt (16.6 KB)
CNvSIPLConsumer_user.hpp.txt (27.5 KB)