From owner-freebsd-arm@freebsd.org Wed May 22 21:35:51 2019 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C9CA015B82BD for ; Wed, 22 May 2019 21:35:50 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound3d.ore.mailhop.org (outbound3d.ore.mailhop.org [54.186.57.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 19E056C10D for ; Wed, 22 May 2019 21:35:49 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1558560948; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=SJaNRLZjWbUau4lMj8dNbCFtNTTtSc7fp7/KFAVCxsi0d5gPBzJGTuyH95ebUQNCPwuNBh/e/ijnl WFruY8+iH2A+gTq816lWsPI2p4X/pV6rfo6AO+nThOZCAio+9i4RzLPSUevcS4vN3ZPB7Z/FLPCYzR WKntzqF3pjxmLCKzAL50OzhwH1zR/BWm/cPMfngZyD4SBB4txIbe2k4UZgVGI1mnIMdLVuZnPAdzfk YwNcsz8ANFQEn+TpUeHNGVca7Bt+C179arCzAUmSp1HAts5DNez46AP8onoCrJAWNRyhRnQvP7gkVp gV0rQkFpp3PE0TzgN98c2OvAhn+XxZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:dkim-signature:from; bh=F4QyK4ecNgi9+1D/bMzqnEg1tyQ1Ud4mdEVju60aUA0=; b=WxkpzSN9Yc/K/vlC9CxgsyDGKMILOrfdgJq1TpGbFVYgVcWbAfYPppAFdSMLO9sWCYD44zhKX2smP clalc7bxdpKpbu8sQs6k6ZugTe3cLtQlEOBxWK0jFo5Opbq29oVSJLcaRoAznNykiX68gfh2vgwsGc x9pwsy72nFgwQdmWeQvNZLCfFZobeJNMf6rO+bHJtJcCkjIrLQi706bbhPhVfa8Dr34Kwg6Txr48lM WX37f8Z6NAQAaX5E6dk2z5jHs7oZ6eZTC7Hjii5y2GT7P+vmwrW1BKi9Dnbcv2ucDMqOzuBDdT6ztv QT13KYzx+lxZBGMWNtwzzsqSS4ladQw== ARC-Authentication-Results: i=1; outbound3.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:from; bh=F4QyK4ecNgi9+1D/bMzqnEg1tyQ1Ud4mdEVju60aUA0=; b=S8aURQ9eaKmQ+/5/kX4LJlcEiaeLpoL55QWOpKbsPI1eHc/xPZUr9sy56ZaxqL0MFQ8IaY2tdLtrE gN5mmCm+rJuA3bGgZhIOy+syfsOyZv7vpyRdrPjA5ZOnryWq443JCJVZ0kYe+mrIzSG97Q7wYt1dtW o5b/0AB77BR2HmXMryz8EInzy54wndn4O0kWg+IYpQnfCxejlBiUvGU5fOkbr7H59ZYGLhNkJzoS8y sIqeKoJOrCkItmfdMxb4Y+QpIH9vOyqJYCXlUlhA/UxVtCgluVhhQCV/9JW7xTAQWgEp0MaM8YOtjW 91bjaNChM/7CKBhGPY2Opiq2eQg4XJg== X-MHO-RoutePath: aGlwcGll X-MHO-User: 8ef64de5-7cd9-11e9-990f-673a89bc4518 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound3.ore.mailhop.org (Halon) with ESMTPSA id 8ef64de5-7cd9-11e9-990f-673a89bc4518; Wed, 22 May 2019 21:35:47 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id x4MLZjOA007187; Wed, 22 May 2019 15:35:45 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: Subject: Re: FreeBsd I2C utility gives same value as MSB and LSB from DS75 sensor 16bit register. From: Ian Lepore To: Karl Denninger , freebsd-arm@freebsd.org, Prasad M Date: Wed, 22 May 2019 15:35:45 -0600 In-Reply-To: <7e6086f1-719a-4b24-e082-feb84d55342f@denninger.net> References: <7e6086f1-719a-4b24-e082-feb84d55342f@denninger.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 19E056C10D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.99 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.987,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:16509, ipnet:54.186.0.0/15, country:US] X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 May 2019 21:35:51 -0000 On Wed, 2019-05-08 at 14:06 -0500, Karl Denninger wrote: > On 5/3/2019 06:43, Prasad M wrote: > > Hi Folks, > > > > I am trying to access a DS75 I2C temperature sensor. It kind of works with > > the default i2c utility. But it returns twice the high byte instead of the > > high and low byte for the temperature. Probably because it does 1 byte > > reads on the I2C bus, sending a stop condition after every byte. > > > > The device expects continuous reads and no stop/start in between the 2 > > bytes. Trying all options i2c, most notably the -m mode switch, yields the > > same results all the time. Looking at the code in i2c.c > > > > Could any one help to solve this problem with working I2CRDWR utility. > > I don't know if you can do it with that utility, but coding up a simple > (~10-15 lines of "C") that reads two bytes is trivially easy. > > You simply stuff a message buffer requesting 2 bytes in response and > call ioctl; you get back two bytes. > This should now be fixed as of r348120 in 13-current, which I will MFC to 12-stable after it gets some testing. The fix adds a new "-m tr" mode. 'tr' is for "transfer", a mode in which the complete set of i2c operations are all handed to the driver at once using I2CRDWR, rather than doing a set of individual START/REPEAT/STOP commands from userland. Some drivers (such as rpi) only work with complete transfers. So, to read the temperature from a DS75, it should now work like: i2c -m tr -a 0x40 -d r -o 0 -w 8 -c 2 -- Ian