Wednesday, April 24, 2019

MCP42100 - 100K with Raspberry Pi 3 model B+ - using spi

MCP42100 is a 100K variable resister controlled using spi interface. The only issue with this one is that it has a very high variation in resistance (high tolerance ) can vary from 70K to 130K

Data sheet - http://ww1.microchip.com/downloads/en/devicedoc/11195c.pdf




Python code for controlling this with SPI


import time
import spidev
import RPi.GPIO as gpio

gpio.setmode(gpio.BCM)
gpio.setup(4,gpio.OUT)

#if you need to open circuit 
#gpio.output(4, gpio.LOW) # Open circuit
#gpio.output(4, gpio.HIGH) # Closed circuit, resistor working


bus = 0 
device = 0

spi = spidev.SpiDev()
spi.open(bus, device)

spi.max_speed_hz = 500000
spi.mode = 0

# try 0 that will set resistance to the min value
res = input("value?")

x = spi.xfer2([19,res])

print(x)


AD5272 - 100K with Raspberry Pi 3 model B+ - using i2c

I am testing this AD5272 digital variable resistor and was really not easy to find any info on how to write to the registers in the ic to change resistance.

Data sheet - https://www.analog.com/media/en/technical-documentation/data-sheets/AD5272_5274.pdf

Useful link - https://stackoverflow.com/questions/46230777/operating-the-ad5272-with-python-3-and-smbus2-on-raspberry-pi-3-b


This is how it work in python,


bus.write_i2c_block_data(Address,First byte,[2nd byte up to 32])

------
import smbus

bus = smbus.SMBus(1)

# This write 0x1c and 0x03 to device with address 0x2c. This unlocks the register
bus.write_i2c_block_data(0x2c,0x1c,[0x03])

# This set the wiper to 0 - get around 30Ohms 
bus.write_i2c_block_data(0x2c,0x04,[0x00])

# This set the wiper to 1023 - get 100K 
bus.write_i2c_block_data(0x2c,0x07,[0xff])

------



I bought this model from DigiKey - AD5272BRMZ-100-RL7CT-ND 

TO solder this I bought a 10MOSP breakout board - LCQT-MSOP10 



Also bought low temperature soldering paste - Chip Quik Inc. / TS391LT 


Used the oven at home to bake it following the graph below.


Used 2.0mm GOOT Desolder Braid to remove soldering bridges 






Sunday, March 4, 2018

Wifi passive site survey using Ekahau



This video describes the process of mapping wifi coverage of an exisiting wifi deployment. Wifi data is collected by listening to beacons, since the software only passively listen to wifi transmissions this is called a passive survey. Ekahau software is the tool that was used for this video, there are other product which has a similar functionality.





Tuesday, February 27, 2018

[WinError 10054] An existing connection was forcibly closed by the remote host

I got this error when I was working on a Python script which use telnet to execute some show commands in Cisco 3650 and Cisco 2960 switches. Strangely I only got this error with Cisco 3650 (16.3.5b) switches.

[WinError 10054] An existing connection was forcibly closed by the remote host 


I was in a rush to get the script working and the work around below fixed the issue. 


1) The most useful method troubleshoot this was enabling debug in telnetlib

telnet = telnetlib.Telnet(ipOfRouterf)
telnet.set_debuglevel(1000)


2) Looking at the output with debugging on, it looked like that this issues is caused by the "exit" command in Cisco CLI.

cmd1 = 'show snmp location'

telnet = telnetlib.Telnet(ipOfRouterf)

telnet.set_debuglevel(1000)

telnet.read_until(b"Username: ",3)

telnet.write(user.encode('ascii') + b"\r\n")

telnet.read_until(b"Password: ",3)

telnet.write(password.encode('ascii') + b"\r\n")

telnet.write(cmd1.encode('ascii')+b"\r\n")

telnet.write(b"exit\r\n")

cmdOUT1 = telnet.read_all().decode('ascii')

print(cmdOUT1)


3) The work around I applied was to remove "exit" ,  enter a command that is invalid but unique so that telnet.read_until('testtest1234') can find it and then use telnet.close() instead of "exit"


cmd1 = 'show cdp neighbor'
cmd2 = 'show snmp location'

telnet = telnetlib.Telnet(ipOfRouterf,timeout = 3)
telnet.set_debuglevel(1000)
  
telnet.read_until(b"Username: ",3)

telnet.write(user.encode('ascii') + b"\r\n")
  
telnet.read_until(b"Password: ",3)
 
telnet.write(password.encode('ascii') + b"\r\n")
  
telnet.write(b"\r\n")
telnet.write(b"\r\n")
telnet.write(cmd1.encode('ascii')+b"\r\n")
telnet.write(b"\r\n")
telnet.write(cmd2.encode('ascii')+b"\r\n")
telnet.write(b"\r\n")
  
telnet.write(b"testtest1234\r\n")
  
cmdOUT1 = telnet.read_until(b"testtest1234").decode('ascii')

telnet.close()

print(cmdOUT1)





Sunday, February 11, 2018

Screen record in Windows using PowerPoint

In Mac OS you can screen record easily using quick time, but in Windows I have been struggling to find a way to do the same. Then I came across this function in PowerPoint. You can use this to screen record and voice over. check the screenshots below.

Windows 10 64bit
MS office professional plus 2016

1) Go to Insert --> Screen Record 


2. Click record . And Windows key + shift  + Q to stop recording




3) Once you stop recording the recorded video will appear as an embedded video in the ppt slide. Right click on the video and save it on to your desktop as a mp4 file.




Thursday, December 14, 2017

Show cisco 2950 switch info from rommon mode

This is how to show the MAC and serial number while you are in rommon mode of Cisco 2950 switch:


switch: flash_init


switch: more flash:env_vars

BOOT=flash:c2950-i6k2l2q4-mz.121-22.EA13.bin
MAC_ADDR=00:0B:FD:60:C0:40
MODEL_NUM=WS-C2950C-24
MODEL_REVISION_NUM=G0
MOTHERBOARD_ASSEMBLY_NUM=73-5710-11
MOTHERBOARD_REVISION_NUM=A0
MOTHERBOARD_SERIAL_NUM=FO1170307Z7
POWER_SUPPLY_PART_NUM=34-091165-01
POWER_SUPPLY_SERIAL_NUM=PHI0648051JE
SYSTEM_SERIAL_NUM=FOC07013AZ0N1

switch:

Thursday, November 30, 2017

SSH to Cisco WLC using Python (3.6) - simple example

import paramiko
import netmiko
from netmiko import ConnectHandler

host = "IP address"
user = "admin"
pw = "xxxxxxx"
platform = "cisco_wlc"


device = ConnectHandler(device_type=platform, ip=host, username=user, password=pw)


output = device.send_command('show wlan 1')

print(output)


device.disconnect()