Dear Community User! We are updating our platform to a new system.
Read more: Important information on the platform change.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

End-user friendly application to plug the SD card in and out for data logging

End-user friendly application to plug the SD card in and out for data logging

Mr_Wonder_Why
Established Member

Hi, I am developing offline data-logging architecture. is it a must to actually access ctrlx UI and click this "mount" button in order for data to be logged into SD card? I do realise that whenever i plug out the SD card and put back in ctrlx, the data will not be written to SD card anymore until i press the "mount" option (shown on the image below).

I want it such that whenever the client wants to record the data to their window device(laptop ,etc) ,  the operator can just plug off the SD card from ctrlx and and plug back in without the need to access ctrlX UI.

P/S: I am using node red to read the input from ctrlX subscribe node and then write into csv file. 

6 REPLIES 6

Sgilk
Frequent Contributor

Hi @Mr_Wonder_Why ,

All of the ctrlX UI functions can be executed via REST API. The mounting portion can be handled this way. See this post for more discussion.

You can also use this API to get the available storage media. You can execute this cyclically in Node-RED to check for the SD card insertion. An example request and response is below. You can check for an unmounted device and then call the mount request using the API.

curl -X 'GET' \
  'https://192.168.1.100/storage/api/v1/media' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJFUzM4NCIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTgzOTk3MTgsImlhdCI6MTcxODM3MDkxOCwiaWQiOiIxMDAwIiwibmFtZSI6ImJvc2NocmV4cm90aCIsIm5vbmNlIjoiOThhNjA0MzgtZGE1Ny00ODgxLWEwNDctMzU4NjlkYWU4MWUyIiwicGxjaGFuZGxlIjowLCJyZW1vdGVhdXRoIjoiIiwic2NvcGUiOlsicmV4cm90aC1kZXZpY2UuYWxsLnJ3eCJdfQ.DE5VFK8vxHnXL7BclcPOx7VZHX04Ddhn-JmC_YWiKR1bh6732Tou8r5Rp5I6rCdhSO7pbC-lAbz1EMCH7MqP5cKLPxrpkkhRmkhbV6aJKXC7rEJxDP2cbBHXbHCA-9K7'
[
  {
    "uuid": "0b43e894-29e1-48d7-bb58-fbde4c3f40c1",
    "label": "ubuntu-data",
    "mounted": true,
    "format": "ext4",
    "size": 2917068800,
    "used": 1981390848,
    "device": "mmcblk0p4",
    "internal": true,
    "parent": "mmcblk0"
  },
  {
    "uuid": "CEA7-20D6",
    "mounted": false,
    "format": "fat32",
    "size": 16294871040,
    "device": "mmcblk1p1",
    "parent": "mmcblk1"
  }
]

 

Mr_Wonder_Why
Established Member

Hi, Ive constructed the node red flow(attached below),  but from my debug response ive gotten data that is irrelevant to what i want( i wanted some thing like mount: false/true) . 

 

P/S: im really new to this REST API, I am not sure how do i integrate this REST API to CtrlX . via what environment or platform do i implement the example code (by @Sgilk )

Sgilk
Frequent Contributor

Hi @Mr_Wonder_Why ,

You can implement this in Node-RED or with the REST client of your choice.

You have a couple of problems with your current implementation.

  1. Your request URL is incorrect to get information on the storage media.
  2. You need to authenticate on the ctrlX OS REST API before issuing further requests.

 You will want to use this endpoint to get the response data I sent above. You can replace localhost with the target ctrlX OS device IP address.

 

https://localhost/storage/api/v1/media

 

If you know the device name or UUID, you can use that information to check the 'mounted' property.

See this video at 27:00 for instruction on obtaining an authentication token to use in your REST API requests

Mr_Wonder_Why
Established Member

Hi @Sgilk 

Ive looked through the video , tried to paste the API endpoint that you suggested above(on top of that, changed "localhost" to my ctrlx ip address). Still couldnt get the Authentication Token. I was wondering how did we actually define what API endpoint we want to access, just copy paste the URL link?( the ctrlx interface that we want to req token from)

 

Sgilk
Frequent Contributor

The REST API endpoints can be found in the interactive Swagger UI documentation. You can use this tool to generate requests. This article does a good job of walking through REST API requests in Node-RED. It is the same process as in the video, so let me know if you still have problems.

Mr_Wonder_Why
Established Member

@Sgilk Hi after going throught the article and numerous trial, ive finally get it to work! Thanks!

 

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist