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.

CCS/C2000WARE-DIGITALPOWER-SDK: CCS/C2000WARE-DIGITALPOWER-SDK

Part Number: C2000WARE-DIGITALPOWER-SDK
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Please help me - I am stuck at downloading of C2000WARE-DIGITALPOWER-SDK.

I downloaded the CCS V10 and from that I surfed about C2000WARE-DIGITALPOWER-SDK and clicked the install button which is available to the right.

After this it is showing error about to download the sdk which is "SOCKET HANG UP ". which is depicted in the below picture.

Please help me with the issue.

  • Jeelka,

    Could you send me the log from <user folder>/tirex-localserver-3.7.1/logs

    I saw from your other thread that you also had issues downloading the software from ti.com.

    Regards,

    John

  • Hi JohnS,

    Thank you so much for your reply.

    First - Please find the logs that you asked for attached below.

    tirex-2020-04-19.log
    {
        "stamp": "2020-04-19T17:09:56.208Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "-----TI-REX started at Sun Apr 19 2020 22:39:56 GMT+0530 (India Standard Time)"
        ]
    },
    {
        "stamp": "2020-04-19T17:09:56.808Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "process.env.HTTP_PROXY=undefined"
        ]
    },
    {
        "stamp": "2020-04-19T17:09:56.808Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "process.env.HTTPS_PROXY=undefined"
        ]
    },
    {
        "stamp": "2020-04-19T17:09:56.808Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "process.env.NO_PROXY=localhost,127.0.0.0,.toro.design.ti.com"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:04.436Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "Version: 3.8.0+201911142334"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:04.437Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "updateServerStatus: initializing"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:04.437Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "DELETING downloads dir"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:04.440Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "DELETING downloads.db"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:04.442Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "content dir: c:\\ti"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:04.442Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "db dir: C:\\Users\\dipik\\ti\\tirex-localserver-3.7.1\\db"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:04.442Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "db logs dir: C:\\Users\\dipik\\ti\\tirex-localserver-3.7.1\\db\\logs"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:04.443Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "sitemap dir: C:\\Users\\dipik\\ti\\tirex-localserver-3.7.1\\db\\sitemap"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:04.443Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "downloads dir: C:\\Users\\dipik\\ti\\tirex-localserver-3.7.1\\downloads"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:04.464Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "DB: use() called with []"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:04.464Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "DB: status {}"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:04.974Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "Waiting for DB ready..."
        ]
    },
    {
        "stamp": "2020-04-19T17:10:05.565Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "Express server listening on port 55432"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:05.565Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "updateServerStatus: up"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:05.577Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "localserver",
            "Starting up local server ..."
        ]
    },
    {
        "stamp": "2020-04-19T17:10:05.586Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "localserver",
            "CCS host: http://localhost:52690/ide/"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:05.605Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "localserver",
            "Start in offline mode with remote server host: http://dev.ti.com/tirex3"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:05.605Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "updateServerStatus: ready"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:05.606Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "Set dbReady=true"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:06.081Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "DB ready"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:08.166Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "DB: use() called with [\"\"]"
        ]
    },
    {
        "stamp": "2020-04-19T17:10:08.166Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "DB: Loading "
        ]
    },
    {
        "stamp": "2020-04-19T17:10:08.173Z",
        "priority": "INFO",
        "facility": "DAEMON",
        "service": "tirex",
        "args": [
            "DB: status {\"\":{\"useCache\":false,\"file\":\"C:\\\\Users\\\\dipik\\\\ti\\\\tirex-localserver-3.7.1\\\\db\\\\resources.db\",\"dbName\":\"resources.db\",\"documents\":\"LOADED\",\"indices\":\"LOADED\",\"cache\":\"LOADED\"}}"
        ]
    },
    
     

    and second - 

    I dont find problem downloading the DIGITALPOWERSDK but I am stuck at installing the same software. I am at a stage where I am unable to find problem whether it is due to some lack of software download or lack of some file.

    I have already downloaded the zip file of DIGITALPOWERSDK from the ti link which says:

    https://www.ti.com/licreg/productdownload.tsp?toPerform=productDownload&location=https%3A%2F%2Fdownloads.ti.com%2Fdownloads%2FC2000%2Fc2000_apps_public_sw%2Fc2000ware_sdk%2Fdigitalpowersdk%2F3_00_00_00%2FC2000Ware_DigitalPower_SDK_3_00_00_00_setup.exe%3F__gda__%3D1587883303_87919c8ee1494593b90a3c869c78d2f9

    and the .exe file also. After doing so I tried installing it locally through this downloaded file. The installation wizard opens up and completes till finish. like u can see in this picture.

    Now when i start CCS v10 and import any project TIDM then it asks me to first install DIGITALPOWERSDK and here when I click the install button it shows me "HANG UP" error message. So please help me with the same.

  • Ok I have passed the log onto the Resource Explorer team to see what is going on.  As far as the import error on asking you to install the DIGITALPOWERSDK lets see if we can correct that.  Basically the projects state that they need this product and CCS is not aware that you have it installed.  

    If you go to Window -> Preferences in CCS.  Navigate to here:

    Add the locaiton where the SDK is installed in the top right box.  Then click refresh and see if it shows the "C2000Ware_DigitalPower_SDK" in the list at the bottom right.  If that shows up you can go back and try to import the project.

    Regards,

    John

  • Thank you Jeelka.

    The team looked at the logs and think that something may be going on with something called TI Cloud Agent, which is a service that Resource Explorer uses.  It has its own set of logs.

    Could you go to: <ccs install dir>/ccs/ccs_base/cloadagent/ticloutagent.bat and add these lines to the top.

    set TI_DS_ENABLE_LOGGING=1
    set TI_DS_LOGGING_OUTPUT=c:/temp/my.log
    REM Note created ticld log file will be modified to C:/temp/my_ticld.log
    REM Note created ds log file will be modified to C:/temp/my.log
    

    In this example above, the log will be located at C:\temp\my_ticld.log.

    Then restart CCS and try to use Resource Explorer again to get the SDK.

    Regards,

    John

  • hey JohnS,

    Look i did these changes in the way you mentioned (refer the image attached)  but still no output.

  • hey JohnS,

    Look i did these changes in the way you mentioned (refer the image attached)  but still no output.

  • Hey JohnS,

    Like you asked to add these lines in the file location mentioned , I did exactly the same thing but now i am getting an error that i could not link to the cloud agent. Refer the same in the attached images.

    Taken the file as mentioned in the path:

    And after refreshing CCS and restarting it, either i click to the install button next to DIGITALPOWERSDK or IMPORT the project from the folder, I am getting the error message that is attached in the next file below:

  • Try using the following lines in the ticloudagent.bat file instead. Note this will add the log file to C:\ti instead. If you point it to a folder which doesn't exist it won't work (which is why it's failing for you).

    set TI_DS_ENABLE_LOGGING=1
    set TI_DS_LOGGING_OUTPUT=C:/ti/my.log
    echo ---ARGS--- %1 %2 %3 > C:/ti/my.log

  • Hi James,

    I got the .bat file correct and now the error for the cloud agent installation is gone.

    But the original problem of unable to install the C2000Ware_DigitalPower_SDK is still coming;  .

     I am stuck at this now please help me and solve this issue. Herewith I am attaching the error 

  • Hi James,

    Also, When I tried to import the project file, it showed me error like shown in the below image.

    I have downloaded the sdk from the ti website http://www.ti.com/tool/C2000WARE-DIGITALPOWER-SDK .

    This gives me a .exe file with which i have installed locally at the same path C:\ti\ and which has all the matadata files and updater.

    And still in CCS while i Want to use DIGITAL POWERSDK from CCS it asks me to install the same and when i click install it downloads, installs, extracts and then does as metioned below:

    Every time i click install, it downloads the sdk in the path i mention C:\ti\  and it starts installation, following extraction and after some times it says "removing" and then gives error.

    Also, JohnS, asked me to do the following:

    Ok I have passed the log onto the Resource Explorer team to see what is going on.  As far as the import error on asking you to install the DIGITALPOWERSDK lets see if we can correct that.  Basically the projects state that they need this product and CCS is not aware that you have it installed.  

    If you go to Window -> Preferences in CCS.  Navigate to here:

    Add the locaiton where the SDK is installed in the top right box.  Then click refresh and see if it shows the "C2000Ware_DigitalPower_SDK" in the list at the bottom right.  If that shows up you can go back and try to import the project.

    And So, in response to this I did this :

    AM I CORRECT ?  

    But still I am getting error of SOCKET HANG UP.

    Please let me know what I should do?

  • The "socket hang up" is an indicator that there is an issue on the cloud agent side.

    Please look for the file "my_ticld.log" in c:\ti and attach it here - hopefully this will give us some info.

    Note that this file gets reset every time you restart CCS. If you could restart CCS, then install one more time, confirm you get the "socket hang up", then attach the file it will help us narrow this down.

  • Hi James G,

    PFA, herewith the updated latest log file that u asked for.

    8463.my_ticld.log

  • Thanks for the log,

    When installing there's 2 servers involved: one to download the package and one to fetch the metadata so you can view the package in tirex while offline. It seems you are able to contact the download server but not the metadata one - the socket hangs up on you after 4 seconds.

    Are you working behind a proxy and/or VPN? If possible could you try outside that proxy / VPN?

    You can also try replacing the file located in "<ccs install location>\ccs\tirex4\ti-rex-core\out\lib\request.js" with the attached file (rename it to request.js). I tried changing some of the settings which may cause the socket to hang up.

    request.txt
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const request = require("request");
    const path = require("path");
    const os = require("os");
    const vars_1 = require("./vars");
    // Allow requests to servers with self signed certs
    process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
    let requestObj;
    function getRequest() {
        if (!requestObj) {
            const version = require(path.join(vars_1.Vars.PROJECT_ROOT, 'package.json')).version;
            // map node's platform names to more commonly used ones in browser user agents
            // (while linux and win32 were recognized by ua-parser, darwin was interpreted incorrectly
            // as linux. Note: This is required to get the correct platform zip when installing packages
            const uaPlatformMap = {
                linux: 'Linux',
                win32: 'Windows NT',
                darwin: 'Macintosh'
            };
            const userAgent = `TirexServer/${version} (${uaPlatformMap[os.platform()]})`;
            const requestDefaults = {
                forever: true,
                jar: true,
                headers: {
                    'User-Agent': userAgent,
                    'Connection': 'keep-alive'
                },
                rejectUnauthorized: false,
                timeout: 60000
            };
            requestObj = request.defaults(requestDefaults);
        }
        return requestObj;
    }
    exports.getRequest = getRequest;

  • Hi JamesG,

    Thanks for the reply. But i am really sorry to say still the error persists "SOCKET HANG UP". with which it is not allowing the software to install.

    I did what you asked for which is replacing the request file but it didnt changed anything,

    And about the VPN or proxy, Acutally i am using a wifi connection to my laptop. and my antivirus is also disabled,

    if you want to refer the logs after what changes u asked for then i m attaching the same below for your reference.

    Kindly help me.4061.my_ticld.log

  • Sorry to hear that,

    Unfortunately this will be a bit of trail and error. For some reason your connection gets aborted but we have no info as to why this happens.

    I added a log to see what server your machine is trying to connect to. If you add the files attached then reply back with a new log we can see what we get.

    "offline-metadata-manager" should go in C:\ti\cs\ccs10.1.0.1\ccs\tirex4\ti-rex-core\out\cloudagent (rename attached file to "offline-metadata-manager.js").

    "offline-product-tree" should go in C:\ti\ccs\ccs10.1.0.1\ccs\tirex4\ti-rex-core\out\cloudagent\offline-metadata-internal (rename attached file to "offline-product-tree.js").

    If it's possible I'd suggest trying to connect to a different network. 

    offline-product-tree.txt
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    // native modules
    const path = require("path");
    // 3rd party modules
    const querystring = require("querystring");
    const fs = require("fs-extra");
    const offline_utils_1 = require("./offline-utils");
    const util_1 = require("../../handoff/util");
    const request_helpers_1 = require("../../shared/request-helpers");
    ///////////////////////////////////////////////////////////////////////////////
    /// Code
    ///////////////////////////////////////////////////////////////////////////////
    /**
     *
     */
    async function offlineProductTreeNoQ({ dbDevices, dbDevtools, rex3Server, tempDirs, installLocation, onProgressUpdate }) {
        // get device or devtool metadata
        const url1 = rex3Server + '/api/devices';
        const url2 = rex3Server + '/api/devtools';
        onProgressUpdate({ progressType: "Indefinite" /* INDEFINITE */, name: `url1 ${url1} url2 ${url2}` });
        const { data: deviceRecords } = await request_helpers_1.doGetRequest(url1);
        const { data: devtoolRecords } = await request_helpers_1.doGetRequest(url2);
        // Assume that if the number of records didn't change the local devDB is in sync with
        // the cloud and skip updating the DB and downloading the images. This is not perfect,
        // but this what rex3 desktop has been doing all along too.
        if (dbDevices.getEntries() === deviceRecords.length &&
            dbDevtools.getEntries() === devtoolRecords.length) {
            return;
        }
        onProgressUpdate({
            progressType: "Indefinite" /* INDEFINITE */,
            name: 'Updating device and devtools records'
        });
        await updateDbDev(dbDevices, deviceRecords);
        await updateDbDev(dbDevtools, devtoolRecords);
        await installDevImageFiles({
            devices: deviceRecords,
            devtools: devtoolRecords,
            rex3Server,
            onProgressUpdate,
            tempDirs,
            installLocation
        });
    }
    exports.offlineProductTreeNoQ = offlineProductTreeNoQ;
    /**
     *
     */
    async function updateDbDev(dbDev, devRecords) {
        await dbDev.removeAsync({});
        await dbDev.insertAsync(devRecords);
        await dbDev.saveAsync();
    }
    /**
     *
     */
    async function installDevImageFiles({ devices, devtools, rex3Server, onProgressUpdate, tempDirs: { downloadDir, extractDir }, installLocation }) {
        const deviceImageFiles = devices.map(record => record.image);
        const devtoolImageFiles = devtools.map(record => record.image);
        const allImageFiles = deviceImageFiles
            .concat(devtoolImageFiles)
            .filter((image) => !!image);
        const downloadUrl = await tirex3RequestArchiveFiles(allImageFiles, rex3Server, onProgressUpdate);
        const zipFilename = await util_1.downloadFile(downloadUrl, downloadDir, onProgressUpdate);
        const items = await util_1.extract(zipFilename, extractDir, onProgressUpdate);
        const productTreeExtractLocation = path.resolve(items[0] || '');
        if (items.length === 1 && productTreeExtractLocation.endsWith('tirex-product-tree')) {
            const productTreeInstallLocation = path.join(installLocation, path.basename(productTreeExtractLocation));
            await fs.remove(productTreeInstallLocation);
            await fs.move(productTreeExtractLocation, productTreeInstallLocation);
        }
        else {
            throw new Error(`Extracted these unexpected folder(s): ${items}`);
        }
    }
    /**
     *
     */
    async function tirex3RequestArchiveFiles(fileList, rex3Server, onProgressUpdate) {
        onProgressUpdate({ progressType: "Indefinite" /* INDEFINITE */, name: 'Archiving files' });
        const progressId = offline_utils_1.generateProgressId();
        const qs = querystring.stringify({
            progressId
        });
        const url = rex3Server + '/api/archivefiles?' + qs;
        const { statusCode } = await request_helpers_1.doPostRequest(url, fileList);
        if (statusCode !== 202) {
            throw new Error('Unexpected status code ' + statusCode);
        }
        const { result: downloadUrlPath } = await offline_utils_1.pollAsync(progressId, rex3Server);
        if (downloadUrlPath.indexOf('NothingToDownload.txt') !== -1) {
            throw new Error(`${url} returned 'NothingToDownload.txt`);
        }
        const downloadUrl = rex3Server + '/' + downloadUrlPath;
        return downloadUrl;
    }
    //# sourceMappingURL=offline-product-tree.js.map
    offline-product-tree.txt
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    // native modules
    const path = require("path");
    // 3rd party modules
    const querystring = require("querystring");
    const fs = require("fs-extra");
    const offline_utils_1 = require("./offline-utils");
    const util_1 = require("../../handoff/util");
    const request_helpers_1 = require("../../shared/request-helpers");
    ///////////////////////////////////////////////////////////////////////////////
    /// Code
    ///////////////////////////////////////////////////////////////////////////////
    /**
     *
     */
    async function offlineProductTreeNoQ({ dbDevices, dbDevtools, rex3Server, tempDirs, installLocation, onProgressUpdate }) {
        // get device or devtool metadata
        const url1 = rex3Server + '/api/devices';
        const url2 = rex3Server + '/api/devtools';
        onProgressUpdate({ progressType: "Indefinite" /* INDEFINITE */, name: `url1 ${url1} url2 ${url2}` });
        const { data: deviceRecords } = await request_helpers_1.doGetRequest(url1);
        const { data: devtoolRecords } = await request_helpers_1.doGetRequest(url2);
        // Assume that if the number of records didn't change the local devDB is in sync with
        // the cloud and skip updating the DB and downloading the images. This is not perfect,
        // but this what rex3 desktop has been doing all along too.
        if (dbDevices.getEntries() === deviceRecords.length &&
            dbDevtools.getEntries() === devtoolRecords.length) {
            return;
        }
        onProgressUpdate({
            progressType: "Indefinite" /* INDEFINITE */,
            name: 'Updating device and devtools records'
        });
        await updateDbDev(dbDevices, deviceRecords);
        await updateDbDev(dbDevtools, devtoolRecords);
        await installDevImageFiles({
            devices: deviceRecords,
            devtools: devtoolRecords,
            rex3Server,
            onProgressUpdate,
            tempDirs,
            installLocation
        });
    }
    exports.offlineProductTreeNoQ = offlineProductTreeNoQ;
    /**
     *
     */
    async function updateDbDev(dbDev, devRecords) {
        await dbDev.removeAsync({});
        await dbDev.insertAsync(devRecords);
        await dbDev.saveAsync();
    }
    /**
     *
     */
    async function installDevImageFiles({ devices, devtools, rex3Server, onProgressUpdate, tempDirs: { downloadDir, extractDir }, installLocation }) {
        const deviceImageFiles = devices.map(record => record.image);
        const devtoolImageFiles = devtools.map(record => record.image);
        const allImageFiles = deviceImageFiles
            .concat(devtoolImageFiles)
            .filter((image) => !!image);
        const downloadUrl = await tirex3RequestArchiveFiles(allImageFiles, rex3Server, onProgressUpdate);
        const zipFilename = await util_1.downloadFile(downloadUrl, downloadDir, onProgressUpdate);
        const items = await util_1.extract(zipFilename, extractDir, onProgressUpdate);
        const productTreeExtractLocation = path.resolve(items[0] || '');
        if (items.length === 1 && productTreeExtractLocation.endsWith('tirex-product-tree')) {
            const productTreeInstallLocation = path.join(installLocation, path.basename(productTreeExtractLocation));
            await fs.remove(productTreeInstallLocation);
            await fs.move(productTreeExtractLocation, productTreeInstallLocation);
        }
        else {
            throw new Error(`Extracted these unexpected folder(s): ${items}`);
        }
    }
    /**
     *
     */
    async function tirex3RequestArchiveFiles(fileList, rex3Server, onProgressUpdate) {
        onProgressUpdate({ progressType: "Indefinite" /* INDEFINITE */, name: 'Archiving files' });
        const progressId = offline_utils_1.generateProgressId();
        const qs = querystring.stringify({
            progressId
        });
        const url = rex3Server + '/api/archivefiles?' + qs;
        const { statusCode } = await request_helpers_1.doPostRequest(url, fileList);
        if (statusCode !== 202) {
            throw new Error('Unexpected status code ' + statusCode);
        }
        const { result: downloadUrlPath } = await offline_utils_1.pollAsync(progressId, rex3Server);
        if (downloadUrlPath.indexOf('NothingToDownload.txt') !== -1) {
            throw new Error(`${url} returned 'NothingToDownload.txt`);
        }
        const downloadUrl = rex3Server + '/' + downloadUrlPath;
        return downloadUrl;
    }
    //# sourceMappingURL=offline-product-tree.js.map

  • Attaching "offline-metadata-manager"

    offline-metadata-manager.txt
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    // native modules
    const fs = require("fs-extra");
    const path = require("path");
    // 3rd party modules
    const PQueue = require("p-queue");
    const rexdb_split_1 = require("../rexdb/lib/rexdb-split");
    const rexdb_1 = require("../rexdb/lib/rexdb");
    const util_1 = require("./util");
    const offline_product_tree_1 = require("./offline-metadata-internal/offline-product-tree");
    const offline_package_metadata_1 = require("./offline-metadata-internal/offline-package-metadata");
    const get_installed_packages_1 = require("./offline-metadata-internal/get-installed-packages");
    const remove_package_metadata_1 = require("./offline-metadata-internal/remove-package-metadata");
    ///////////////////////////////////////////////////////////////////////////////
    /// Code
    ///////////////////////////////////////////////////////////////////////////////
    /**
     * This class is responsible for managing the rex3 local database content
     *  - querying for what packages are local
     *  - detecting and removing database entries for removed packages
     *  - downloading new database content and updating the existing .db files when requested
     */
    class OfflineMetadataManager {
        constructor(commonParams) {
            this.commonParams = commonParams;
            this.databaseQueue = new PQueue({ concurrency: 1 });
            const dbPath = this.commonParams.rex3Config.dbPath;
            fs.ensureDirSync(dbPath);
            this.dbDevices = new rexdb_1.RexDB(this.commonParams.logger, path.join(dbPath, 'devices.db'));
            this.dbDevtools = new rexdb_1.RexDB(this.commonParams.logger, path.join(dbPath, 'devtools.db'));
            this.dbResources = new rexdb_split_1.RexDBSplit(this.commonParams.logger, path.join(dbPath, 'resources.db'));
            this.dbOverviews = new rexdb_1.RexDB(this.commonParams.logger, path.join(dbPath, 'overviews.db'));
            this.dbPureBundles = new rexdb_1.RexDB(this.commonParams.logger, path.join(dbPath, 'bundles.db'));
        }
        /**
         *  Return package infos for all installed (offlined) packages based on dbOverviews
         */
        async getInstalledPackages() {
            return this.databaseQueue.add(() => get_installed_packages_1.getInstalledPackagesNoQ(this.dbOverviews));
        }
        /**
         * Queue up fetching the metadata of a software package and insertiing it into the offline DB.
         * Update the offline product tree (devices and devtools DB) if needed.
         * Send event that packages were updated.
         */
        async offlinePackageMetadata(packagePublicUid, installPackageFolder, onProgressUpdate, ignorePackageNotOnServer = false) {
            this.commonParams.logger.info(`start offlinePackageMetadata of package ${packagePublicUid}`);
            onProgressUpdate({
                progressType: "Indefinite" /* INDEFINITE */,
                name: 'Updating metadata'
            });
            const defaultInstallPath = this.commonParams.rex3Config.contentPath; // typically c:\ti or ~/ti
            const rex3Server = this.commonParams.rex3Config.remoteserverHost;
            const productTreeTempDirs = await util_1.makeTempDirs(defaultInstallPath, 'product-tree');
            const packageMetadataTempDirs = await util_1.makeTempDirs(defaultInstallPath, 'package-metadata');
            this.commonParams.logger.info(`going to rex3 ${rex3Server}`);
            try {
                const dst = await offline_package_metadata_1.downloadAndExtractPackageMetadata(packagePublicUid, packageMetadataTempDirs, onProgressUpdate, rex3Server);
                await this.databaseQueue.add(async () => {
                    // update product tree if needed
                    this.commonParams.logger.info(`updateOfflineProductTree`);
                    await offline_product_tree_1.offlineProductTreeNoQ({
                        dbDevices: this.dbDevices,
                        dbDevtools: this.dbDevtools,
                        rex3Server,
                        tempDirs: productTreeTempDirs,
                        installLocation: defaultInstallPath,
                        onProgressUpdate
                    });
                });
                await this.databaseQueue.add(async () => {
                    // fetch package metadata
                    this.commonParams.logger.info(`offlinePackageMetadata: ${packagePublicUid}`);
                    await offline_package_metadata_1.offlinePackageMetadataNoQ({
                        packagePublicUid,
                        dbResources: this.dbResources,
                        dbOverviews: this.dbOverviews,
                        dbPureBundles: this.dbPureBundles,
                        installPackageFolder,
                        onProgressUpdate,
                        rex3Server,
                        dstPath: dst
                    });
                    const packages = await get_installed_packages_1.getInstalledPackagesNoQ(this.dbOverviews);
                    this.commonParams.triggerEvent("OnInstalledPackagesUpdated" /* ON_INSTALLED_PACKAGES_UPDATED */, packages);
                    this.commonParams.logger.info(`done offlinePackageMetadata: ${packagePublicUid}`);
                });
            }
            catch (err) {
                if (ignorePackageNotOnServer &&
                    err.message &&
                    err.message.includes(`Bundle ${packagePublicUid} not found`)) {
                    this.commonParams.logger.info(`offlinePackageMetadata: Ignoring that ${packagePublicUid} was not found on the remoter server because it was removed or is not a tirex package`);
                }
                else {
                    throw err;
                }
            }
            finally {
                try {
                    onProgressUpdate({ progressType: "Indefinite" /* INDEFINITE */, name: 'Cleaning up' });
                }
                catch (e) {
                    this.commonParams.logger.error('ignoring progress exception in finally: ' + e.message);
                }
                await Promise.all([
                    util_1.removeTempDirs(productTreeTempDirs),
                    util_1.removeTempDirs(packageMetadataTempDirs)
                ]);
            }
        }
        /**
         *  Queue up removing the offline metadata of a software package.
         *  Send event that packages were updated.
         */
        async removePackageMetadata(packagePublicUid, onProgressUpdate) {
            await this.databaseQueue.add(async () => {
                await remove_package_metadata_1.removePackageMetadataNoQ(packagePublicUid, this.dbResources, this.dbOverviews, this.dbPureBundles, onProgressUpdate);
                const remainingPackages = await get_installed_packages_1.getInstalledPackagesNoQ(this.dbOverviews);
                this.commonParams.triggerEvent("OnInstalledPackagesUpdated" /* ON_INSTALLED_PACKAGES_UPDATED */, remainingPackages);
            });
        }
    }
    exports.OfflineMetadataManager = OfflineMetadataManager;
    //# sourceMappingURL=offline-metadata-manager.js.map

  • Hey James, There is a good news and a bad news too...

    Good news is that the software got installed in one of the devices that i was looking for. Thanks for your kind help.

    And the bad news is that it didnt work out for the other.

    Actually, while trying on my laptop like we discussed these tricks as i was unable to install the software DIGITALPOWERSDK, I started working on the other one i had. I was getting same errors in both the Laptops. Until lastly after u asked me to replace the metadata file for new logs and after this it got installed in one of the laptops and got success. I cant say at which point and after what changes i did , i was successful in installing the software, because even after replacing the "REQUEST" file i was not successful. but after u asked me to change the metadata files something worked out and it got installed in this device.

    I tried in other laptop BECAUSE when u asked to change the network i thought about changing the device and so i started working on that device., the other laptop. 

    But now as i have been able to download in this one i am worried about where to start for the other one as it is showing me the same error SOCKET HANG UP.

    Please can u suggest me and help me to resolve this issue and specifically the sequence to follow to resolve it...

  • The only change that could actually fix it is the "request" file. The other ones were just to get some more info. Did you restart CCS after changing the files? It will only take effect after restarting CCS.

    Thanks for trying it on 2 different laptops. Since you see the same problem on both machines it's likely a network issue.  My guess is your network doesn't like the responses from the "metadata" server for some reason (so it just "hangs up" on the response). It could be for a number of reasons.

    Note you don't need to install from tirex, you can just install using the installer you obtained from ti.com. I'd suggest you install it though this method for now. 

  • Hi James,

    Yes , I did restart CCS after replacing the files, but still error came. And after changing the metadata files and restarting the CCS the installation was successful.

    And for the other machine I don’t have any TiCloudagent downloaded and installed, so do I need to install that first or just by replacing the “request” file the problem will be solved? And just for the information both the machines were under different networks and different places too; One was at my place and other at the office. Also, I tried using different WiFi conditions and even mobile data. But still seeing the same error. And actually that’s reason I wrote for a query in this forum.

    Moreover, I didnot understand your last point, of not downloading or installing it from tirex. Can u explain me in detail please, the method which you are talking about .

  • Interesting that changing the metadata files fixed it. Does it work consistently now? 

    On the other machine all the files I pointed to should already be there if you installed CCS. You just need to replace them with what I posted in my previous comments.

    Is your end goal to import a project from the package? If so you can just install it from the link from before https://www.ti.com/licreg/productdownload.tsp?toPerform=productDownload&location=https%3A%2F%2Fdownloads.ti.com%2Fdownloads%2FC2000%2Fc2000_apps_public_sw%2Fc2000ware_sdk%2Fd. You don't need to use the install button in CCS, it's just for convenience, downloading from this link will work as well. 

  • Hi JamesG,

    Sorry for replying late... But I was trying in different machines for seeing the pattern about downloading the software DIGITALPOWERSDK.

    I am happy to share with you that i am successful to download and consistently using the software properly. But i observed a sequence that when the machines are connected to wifi then the download fails for sure no matter what you do but as soon as i connected the mobile hotspot internet to the software for downloading and installing it worked out succesfull.

    Anyways now i can work with the software and so i have succesfully achieved my aim. 

    So Thankyou so much for the help and continuous efforts that you tried to make me achieve my goal. Thanks a lot.

    Thanks 

    Regards,