[GitHub] microbuilder commented on issue #1251: Added stubs for I2C simulation

2018-07-11 Thread GitBox
microbuilder commented on issue #1251: Added stubs for I2C simulation
URL: https://github.com/apache/mynewt-core/pull/1251#issuecomment-404136064
 
 
   Think this can get merged if there are no other issues you see, and then I 
can push out some test code for it via an update to PR #1237 ? I don't have 
merge rights myself.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] microbuilder commented on issue #1251: Added stubs for I2C simulation

2018-07-11 Thread GitBox
microbuilder commented on issue #1251: Added stubs for I2C simulation
URL: https://github.com/apache/mynewt-core/pull/1251#issuecomment-404067578
 
 
   Let me know if you think the printf additions in hal_i2c.c are too chatty, 
and I can either make them optional or reduce them. The current output is as 
follows (using a TSL2591 simulator I'm working on):
   
   ```
   uart0 at /dev/ttys002
   Registering TSL2591 sim driver
   Registering I2C sim driver for 0x29
   TSL2591 wrote 2 byte(s): 0xA0 0x03
   TSL2591 wrote 1 byte(s): 0xA1
   TSL2591  read 1 byte(s): 0x00
   TSL2591 wrote 2 byte(s): 0xA1 0x00
   TSL2591 wrote 1 byte(s): 0xA1
   TSL2591  read 1 byte(s): 0x00
   TSL2591 wrote 2 byte(s): 0xA1 0x00
   ```
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] microbuilder commented on issue #1251: Added stubs for I2C simulation

2018-07-11 Thread GitBox
microbuilder commented on issue #1251: Added stubs for I2C simulation
URL: https://github.com/apache/mynewt-core/pull/1251#issuecomment-404066699
 
 
   Sorry to contradict myself, but I went ahead and added the registration and 
redirection changes to this PR since I got them working here last night. See 
3e8c92c


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] microbuilder commented on issue #1251: Added stubs for I2C simulation

2018-07-10 Thread GitBox
microbuilder commented on issue #1251: Added stubs for I2C simulation
URL: https://github.com/apache/mynewt-core/pull/1251#issuecomment-403980164
 
 
   @vrahane I'm working on defining the API right now, including `SLIST` etc. 
to have a list of registered simulated devices, but it will take me a bit of 
time to wrap my head around how to organize things well since it crosses a 
couple packages. The code in this PR is useful to get the stubs in there, 
though, and gives useful printf output when I2C access occurs similar to what 
GPIO current does.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] microbuilder commented on issue #1251: Added stubs for I2C simulation

2018-07-10 Thread GitBox
microbuilder commented on issue #1251: Added stubs for I2C simulation
URL: https://github.com/apache/mynewt-core/pull/1251#issuecomment-403967036
 
 
   @mkiiskila I need a bit more time to put together the sensor sim API and 
some test code for it. I'm actively working on it, but if you're OK with a 
second PR for sim that makes more sense to me???


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] microbuilder commented on issue #1251: Added stubs for I2C simulation

2018-07-10 Thread GitBox
microbuilder commented on issue #1251: Added stubs for I2C simulation
URL: https://github.com/apache/mynewt-core/pull/1251#issuecomment-403898073
 
 
   @mkiiskila I've been working on this on my fork, but if you're OK to merge 
the PR in as is to get some basic print stubs in the codebase, I'll put 
together a proposal for a sensor simulator in a new PR?
   
   SLIST needs to be implemented, yes, and if addr is provided we can drop 
probe yes. I can't think of any edge cases where I'd want or need to handle 
that elsewhere.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] microbuilder commented on issue #1251: Added stubs for I2C simulation

2018-07-09 Thread GitBox
microbuilder commented on issue #1251: Added stubs for I2C simulation
URL: https://github.com/apache/mynewt-core/pull/1251#issuecomment-403414409
 
 
   This PR is functional in and of itself, and can be merged in on it's own, 
but to simulate an actual I2C sensor we will also need to consider how the 
actual device simulation should be implemented in a manageable way.
   
   My own opinion is that the `_sim.c` implementation should be 
part of the sensor driver package, and there could perhaps be an addition to 
`hal_i2c` to allow simulated drivers to be registered, with 
init/read/write/probe calls passed up to the sensor driver package via a series 
of callbacks.
   
   Something similar to the following, perhaps (adding a file named 
`hal_i2c_sim.h`)?:
   
   > **Note**: This simple header file doesn't take simulator registration or 
handling into account, it's just an example to try to generate some further 
discussion
   
   ```
   /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/
   
   
   /**
* @addtogroup HAL
* @{
*   @defgroup HALI2cSim HAL I2c sim
*   @{
*/
   
   #ifndef H_HAL_I2C_SIM_
   #define H_HAL_I2C_SIM_
   
   #include 
   
   #ifdef __cplusplus
   extern "C" {
   #endif
   
   /**
* Initialize a new i2c device with the I2C number.
*
* @param i2c_num The number of the I2C device being initialized
* @param cfg The hardware specific configuration structure to configure
*the I2C with.  This includes things like pin configuration.
*
* @return 0 on success, and non-zero error code on failure
*/
   typedef int (*hal_i2c_sim_init_t)(uint8_t i2c_num, void *cfg);
   
   /**
* Sends a start condition and writes  bytes of data on the i2c bus.
* This API does NOT issue a stop condition unless `last_op` is set to `1`.
* You must stop the bus after successful or unsuccessful write attempts.
* This API is blocking until an error or NaK occurs. Timeout is platform
* dependent.
*
* @param i2c_num The number of the I2C device being written to
* @param pdata The data to write to the I2C bus
* @param timeout How long to wait for transaction to complete in ticks
* @param last_op Master should send a STOP at the end to signify end of
*transaction.
*
* @return 0 on success, and non-zero error code on failure
*/
   typedef int (*hal_i2c_sim_master_write_t)(uint8_t i2c_num,
struct hal_i2c_master_data *pdata, uint32_t timeout,
uint8_t last_op);
   
   /**
   * Sends a start condition and reads  bytes of data on the i2c bus.
   * This API does NOT issue a stop condition unless `last_op` is set to `1`.
   * You must stop the bus after successful or unsuccessful write attempts.
   * This API is blocking until an error or NaK occurs. Timeout is platform
   * dependent.
   *
   * @param i2c_num The number of the I2C device being written to
   * @param pdata The location to place read data
   * @param timeout How long to wait for transaction to complete in ticks
   * @param last_op Master should send a STOP at the end to signify end of
   *transaction.
   *
   * @return 0 on success, and non-zero error code on failure
   */
   typedef int (*hal_i2c_sim_master_read_t)(uint8_t i2c_num,
struct hal_i2c_master_data *pdata,
uint32_t timeout, uint8_t last_op);
   
   /**
   * Probes the i2c bus for a device with this address.  THIS API
   * issues a start condition, probes the address using a read
   * command and issues a stop condition.
   *
   * @param i2c_num The number of the I2C to probe
   * @param address The address to probe for
   * @param timeout How long to wait for transaction to complete in ticks
   *
   * @return 0 on success, non-zero error code on failure
   */
   typedef int (*hal_i2c_sim_master_probe_t)(uint8_t i2c_num, uint8_t address,
uint32_t timeout);
   
   struct hal_i2c_sim_driver {
   hal_i2c_sim_init_t sd_init;
   hal_i2c_sim_master_write_t sd_write;
   hal_i2c_sim_master_read_t sd_read;
   hal_i2c_sim_master_probe_t sd_probe;
   };
   
   #ifdef __cplusplus
   }
   #endif
   

[GitHub] microbuilder commented on issue #1251: Added stubs for I2C simulation

2018-07-07 Thread GitBox
microbuilder commented on issue #1251: Added stubs for I2C simulation
URL: https://github.com/apache/mynewt-core/pull/1251#issuecomment-403250628
 
 
   The goal here is to be able to simulate specific I2C sensors when HW isn't 
available, or when it isn't possible to test under repeatable conditions in the 
real world (edge cases can be generated in the simulator, etc.).
   
   Sensor-specific emulators can be introduced, and they can be called based on 
the I2C address provided to the function stubs here, although it's worth 
discussing how and where the sensor sim implementations should be added to the 
system.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services