{"action":"created","issue":{"url":"https://api.github.com/repos/pyepics/pyepics/issues/53","repository_url":"https://api.github.com/repos/pyepics/pyepics","labels_url":"https://api.github.com/repos/pyepics/pyepics/issues/53/labels{/name}","comments_url":"https://api.github.com/repos/pyepics/pyepics/issues/53/comments","events_url":"https://api.github.com/repos/pyepics/pyepics/issues/53/events","html_url":"https://github.com/pyepics/pyepics/pull/53","id":131496292,"number":53,"title":"Fix scalar len and zero-length strings","user":{"login":"klauer","id":5139267,"avatar_url":"https://avatars.githubusercontent.com/u/5139267?v=3","gravatar_id":"","url":"https://api.github.com/users/klauer","html_url":"https://github.com/klauer","followers_url":"https://api.github.com/users/klauer/followers","following_url":"https://api.github.com/users/klauer/following{/other_user}","gists_url":"https://api.github.com/users/klauer/gists{/gist_id}","starred_url":"https://api.github.com/users/klauer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klauer/subscriptions","organizations_url":"https://api.github.com/users/klauer/orgs","repos_url":"https://api.github.com/users/klauer/repos","events_url":"https://api.github.com/users/klauer/events{/privacy}","received_events_url":"https://api.github.com/users/klauer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-02-04T22:44:28Z","updated_at":"2016-02-05T17:54:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pyepics/pyepics/pulls/53","html_url":"https://github.com/pyepics/pyepics/pull/53","diff_url":"https://github.com/pyepics/pyepics/pull/53.diff","patch_url":"https://github.com/pyepics/pyepics/pull/53.patch"},"body":"I ran into further issues with zero-length strings and some scalar-value related oddities. Here are two small fixes: both should be minor enough as to not break anything else. Added 2 tests for these. Cousin PR is pyepics/testioc#3.\r\n\r\nExample PV:\r\n```sh\r\n$ caget -Sc 'XF:31IDA-BI{Cam:Tbl}cam1:StringFromServer_RBV'\r\nXF:31IDA-BI{Cam:Tbl}cam1:StringFromServer_RBV 0\r\n```\r\n\r\nCase 1 that was failing (non-automonitored waveform char as string):\r\n```python\r\nIn [1]: epics.PV('XF:31IDA-BI{Cam:Tbl}cam1:StringFromServer_RBV', auto_monitor=False).get(as_string=True)\r\n\r\npyepics/epics/pv.py in get(self, count, as_string, as_numpy, timeout, with_ctrlvars, use_monitor)\r\n    290         val = self._args['value']\r\n    291         if as_string:\r\n--> 292             return self._set_charval(val)\r\n    293         if self.count <= 1 or val is None:\r\n    294             return val\r\n\r\npyepics/epics/pv.py in _set_charval(self, val, call_ca)\r\n    360             elif self.count==1: # handles single character in waveform\r\n    361                 val = [val]\r\n--> 362             val = list(val)\r\n    363             if 0 in val:\r\n    364                 firstnull  = val.index(0)\r\n\r\nTypeError: 'int' object is not iterable\r\n```\r\n\r\nCase 2:\r\n```python\r\nIn [2]: epics.PV('XF:31IDA-BI{Cam:Tbl}cam1:StringFromServer_RBV', auto_monitor=False).get()\r\n\r\npyepics/epics/pv.py in get(self, count, as_string, as_numpy, timeout, with_ctrlvars, use_monitor)\r\n    295\r\n    296         if count is None:\r\n--> 297             count = len(val)\r\n    298         if (as_numpy and ca.HAS_NUMPY and\r\n    299             not isinstance(val, ca.numpy.ndarray)):\r\n\r\nTypeError: object of type 'int' has no len()\r\n```\r\n\r\nWith this PR:\r\n```python\r\nIn [1]: epics.PV('XF:31IDA-BI{Cam:Tbl}cam1:StringFromServer_RBV', auto_monitor=False).get()\r\nOut[1]: 0\r\n\r\nIn [2]: epics.PV('XF:31IDA-BI{Cam:Tbl}cam1:StringFromServer_RBV', auto_monitor=False).get(as_string=True)\r\nOut[2]: ''\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/pyepics/pyepics/issues/comments/180468975","html_url":"https://github.com/pyepics/pyepics/pull/53#issuecomment-180468975","issue_url":"https://api.github.com/repos/pyepics/pyepics/issues/53","id":180468975,"user":{"login":"klauer","id":5139267,"avatar_url":"https://avatars.githubusercontent.com/u/5139267?v=3","gravatar_id":"","url":"https://api.github.com/users/klauer","html_url":"https://github.com/klauer","followers_url":"https://api.github.com/users/klauer/followers","following_url":"https://api.github.com/users/klauer/following{/other_user}","gists_url":"https://api.github.com/users/klauer/gists{/gist_id}","starred_url":"https://api.github.com/users/klauer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klauer/subscriptions","organizations_url":"https://api.github.com/users/klauer/orgs","repos_url":"https://api.github.com/users/klauer/repos","events_url":"https://api.github.com/users/klauer/events{/privacy}","received_events_url":"https://api.github.com/users/klauer/received_events","type":"User","site_admin":false},"created_at":"2016-02-05T17:54:21Z","updated_at":"2016-02-05T17:54:21Z","body":"@newville Not a problem - good that we're on the same page now. As far as how to fix it (properly?) that's another story..."}}