MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / dev_open

Function dev_open

libsigrok4DSL/session_driver.c:736–780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

734}
735
736static int dev_open(struct sr_dev_inst *sdi)
737{
738 int ret;
739 struct session_vdev *vdev;
740
741 assert(sdi);
742
743 if (sdi->status == SR_ST_ACTIVE){
744 // Is opened.
745 return SR_OK;
746 }
747
748 assert(sdi->priv == NULL);
749
750 vdev = malloc(sizeof(struct session_vdev));
751 if (vdev == NULL)
752 {
753 sr_err("%s: sdi->priv malloc failed", __func__);
754 return SR_ERR_MALLOC;
755 }
756 memset(vdev, 0, sizeof(struct session_vdev));
757
758 vdev->max_timebase = MAX_TIMEBASE;
759 vdev->min_timebase = MIN_TIMEBASE;
760 vdev->mstatus.measure_valid = TRUE;
761 vdev->unit_bits = 1;
762
763 sdi->priv = vdev;
764 sdi->status = SR_ST_ACTIVE;
765
766 vdev->buf = malloc(CHUNKSIZE + sizeof(uint64_t));
767 if (vdev->buf == NULL){
768 sr_err("%s: vdev->buf malloc failed", __func__);
769 return SR_ERR_MALLOC;
770 }
771
772 ret = sr_load_virtual_device_session(sdi);
773 if (ret != SR_OK)
774 {
775 sr_err("Error!Load session file failed.");
776 return ret;
777 }
778
779 return SR_OK;
780}
781
782static void free_temp_buffer(struct session_vdev *vdev)
783{

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected