Compare commits
28 Commits
Author | SHA1 | Date |
---|---|---|
wiebel | 51605d8d1c | 2 years ago |
wiebel | 4eece42354 | 3 years ago |
wiebel | d0fbfa4481 | 3 years ago |
wiebel | e1f4675ef8 | 4 years ago |
wiebel | d32e0b6ee5 | 4 years ago |
wiebel | dded78cb83 | 4 years ago |
root | 4fd5096c96 | 4 years ago |
root | 41d2190488 | 4 years ago |
root | d6f9989379 | 4 years ago |
root | e30963a990 | 4 years ago |
root | e6da99b4a6 | 4 years ago |
root | f241e7cf04 | 4 years ago |
root | dfab0e57be | 4 years ago |
wiebel | 8310c0dd7f | 4 years ago |
wiebel | d68451e48b | 4 years ago |
wiebel | b1ae22b367 | 5 years ago |
wiebel | b26c97e136 | 5 years ago |
root | 896580a239 | 5 years ago |
mwaiblinger | 6a76239f40 | 5 years ago |
root | 55817da407 | 5 years ago |
mwaiblinger | 584c263eaa | 5 years ago |
root | 42db319ae9 | 5 years ago |
mwaiblinger | 81cebe6472 | 5 years ago |
mwaiblinger | 732b91caef | 5 years ago |
wiebel | 35263d8595 | 5 years ago |
wiebel | 15de286b3f | 5 years ago |
wiebel | 4b22b19ab6 | 5 years ago |
wiebel | 77b927d1fc | 5 years ago |
@ -0,0 +1,43 @@ |
|||
update=Tue Oct 22 14:04:36 2019 |
|||
version=1 |
|||
last_client=eeschema |
|||
[general] |
|||
version=1 |
|||
RootSch= |
|||
BoardNm= |
|||
[pcbnew] |
|||
version=1 |
|||
LastNetListRead= |
|||
UseCmpFile=1 |
|||
PadDrill=0.600000000000 |
|||
PadDrillOvalY=0.600000000000 |
|||
PadSizeH=1.500000000000 |
|||
PadSizeV=1.500000000000 |
|||
PcbTextSizeV=1.500000000000 |
|||
PcbTextSizeH=1.500000000000 |
|||
PcbTextThickness=0.300000000000 |
|||
ModuleTextSizeV=1.000000000000 |
|||
ModuleTextSizeH=1.000000000000 |
|||
ModuleTextSizeThickness=0.150000000000 |
|||
SolderMaskClearance=0.000000000000 |
|||
SolderMaskMinWidth=0.000000000000 |
|||
DrawSegmentWidth=0.200000000000 |
|||
BoardOutlineThickness=0.100000000000 |
|||
ModuleOutlineThickness=0.150000000000 |
|||
[cvpcb] |
|||
version=1 |
|||
NetIExt=net |
|||
[eeschema] |
|||
version=1 |
|||
LibDir= |
|||
[eeschema/libraries] |
|||
[schematic_editor] |
|||
version=1 |
|||
PageLayoutDescrFile= |
|||
PlotDirectoryName= |
|||
SubpartIdSeparator=0 |
|||
SubpartFirstId=65 |
|||
NetFmtName= |
|||
SpiceAjustPassiveValues=0 |
|||
LabSize=50 |
|||
ERC_TestSimilarLabels=1 |
@ -0,0 +1,419 @@ |
|||
EESchema Schematic File Version 4 |
|||
LIBS:DiffWS2811-cache |
|||
EELAYER 26 0 |
|||
EELAYER END |
|||
$Descr A4 11693 8268 |
|||
encoding utf-8 |
|||
Sheet 1 1 |
|||
Title "" |
|||
Date "" |
|||
Rev "" |
|||
Comp "" |
|||
Comment1 "" |
|||
Comment2 "" |
|||
Comment3 "" |
|||
Comment4 "" |
|||
$EndDescr |
|||
$Comp |
|||
L 000_my_lib:DSN-MINI-360 MOD1 |
|||
U 1 1 5C0664F1 |
|||
P 2900 3550 |
|||
F 0 "MOD1" H 2900 3500 50 0000 C CNN |
|||
F 1 "DSN-MINI-360" H 3125 3934 50 0001 C CNN |
|||
F 2 "000_my_footprints:DC-DC" H 3150 3700 50 0001 C CNN |
|||
F 3 "" H 3150 3700 50 0001 C CNN |
|||
1 2900 3550 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
$Comp |
|||
L Interface_UART:MAX485E U1 |
|||
U 1 1 5C06691A |
|||
P 3850 2300 |
|||
F 0 "U1" H 4100 1750 50 0000 C CNN |
|||
F 1 "MAX485E" H 3650 1750 50 0000 C CNN |
|||
F 2 "Package_SO:SOIC-8_3.9x4.9mm_P1.27mm" H 3850 1600 50 0001 C CNN |
|||
F 3 "https://datasheets.maximintegrated.com/en/ds/MAX1487E-MAX491E.pdf" H 3850 2350 50 0001 C CNN |
|||
1 3850 2300 |
|||
-1 0 0 -1 |
|||
$EndComp |
|||
$Comp |
|||
L Device:R_Small R1 |
|||
U 1 1 5C066BB7 |
|||
P 3150 2350 |
|||
F 0 "R1" H 3209 2350 50 0000 L CNN |
|||
F 1 "R_Small" H 3209 2305 50 0001 L CNN |
|||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 3150 2350 50 0001 C CNN |
|||
F 3 "~" H 3150 2350 50 0001 C CNN |
|||
1 3150 2350 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
$Comp |
|||
L Connector_Generic:Conn_01x04 J1 |
|||
U 1 1 5C066D15 |
|||
P 2750 2400 |
|||
F 0 "J1" H 2670 1975 50 0000 C CNN |
|||
F 1 "Conn_01x04" H 3200 2100 50 0001 C CNN |
|||
F 2 "Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_Vertical" H 2750 2400 50 0001 C CNN |
|||
F 3 "~" H 2750 2400 50 0001 C CNN |
|||
1 2750 2400 |
|||
-1 0 0 1 |
|||
$EndComp |
|||
$Comp |
|||
L Connector_Generic:Conn_01x03 J2 |
|||
U 1 1 5C066E44 |
|||
P 4850 2200 |
|||
F 0 "J2" H 4930 2196 50 0000 L CNN |
|||
F 1 "Conn_01x03" H 4930 2151 50 0001 L CNN |
|||
F 2 "Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical" H 4850 2200 50 0001 C CNN |
|||
F 3 "~" H 4850 2200 50 0001 C CNN |
|||
1 4850 2200 |
|||
1 0 0 1 |
|||
$EndComp |
|||
$Comp |
|||
L Device:C_Small C1 |
|||
U 1 1 5C066F30 |
|||
P 4150 3350 |
|||
F 0 "C1" H 4242 3396 50 0000 L CNN |
|||
F 1 "C_Small" H 4242 3305 50 0001 L CNN |
|||
F 2 "Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 4150 3350 50 0001 C CNN |
|||
F 3 "~" H 4150 3350 50 0001 C CNN |
|||
1 4150 3350 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
$Comp |
|||
L Device:Jumper_NO_Small JP1 |
|||
U 1 1 5C066FFC |
|||
P 3100 3200 |
|||
F 0 "JP1" H 3100 3385 50 0000 C CNN |
|||
F 1 "Jumper" H 3100 3294 50 0000 C CNN |
|||
F 2 "Jumper:SolderJumper-2_P1.3mm_Open_RoundedPad1.0x1.5mm" H 3100 3200 50 0001 C CNN |
|||
F 3 "~" H 3100 3200 50 0001 C CNN |
|||
1 3100 3200 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
$Comp |
|||
L power:GND #PWR0101 |
|||
U 1 1 5C0670C6 |
|||
P 3000 2550 |
|||
F 0 "#PWR0101" H 3000 2300 50 0001 C CNN |
|||
F 1 "GND" H 3005 2377 50 0001 C CNN |
|||
F 2 "" H 3000 2550 50 0001 C CNN |
|||
F 3 "" H 3000 2550 50 0001 C CNN |
|||
1 3000 2550 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
$Comp |
|||
L power:VCC #PWR0102 |
|||
U 1 1 5C067142 |
|||
P 3850 1750 |
|||
F 0 "#PWR0102" H 3850 1600 50 0001 C CNN |
|||
F 1 "VCC" H 4000 1800 50 0000 C CNN |
|||
F 2 "" H 3850 1750 50 0001 C CNN |
|||
F 3 "" H 3850 1750 50 0001 C CNN |
|||
1 3850 1750 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
$Comp |
|||
L power:-VSW #PWR0103 |
|||
U 1 1 5C06719C |
|||
P 3000 2150 |
|||
F 0 "#PWR0103" H 3000 2250 50 0001 C CNN |
|||
F 1 "-VSW" H 3015 2323 50 0000 C CNN |
|||
F 2 "" H 3000 2150 50 0001 C CNN |
|||
F 3 "" H 3000 2150 50 0001 C CNN |
|||
1 3000 2150 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
$Comp |
|||
L power:GND #PWR0104 |
|||
U 1 1 5C067280 |
|||
P 3100 3700 |
|||
F 0 "#PWR0104" H 3100 3450 50 0001 C CNN |
|||
F 1 "GND" H 3105 3527 50 0001 C CNN |
|||
F 2 "" H 3100 3700 50 0001 C CNN |
|||
F 3 "" H 3100 3700 50 0001 C CNN |
|||
1 3100 3700 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
$Comp |
|||
L power:-VSW #PWR0106 |
|||
U 1 1 5C0672B2 |
|||
P 2750 3150 |
|||
F 0 "#PWR0106" H 2750 3250 50 0001 C CNN |
|||
F 1 "-VSW" H 2765 3323 50 0000 C CNN |
|||
F 2 "" H 2750 3150 50 0001 C CNN |
|||
F 3 "" H 2750 3150 50 0001 C CNN |
|||
1 2750 3150 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
$Comp |
|||
L power:VCC #PWR0107 |
|||
U 1 1 5C0672DA |
|||
P 3450 3150 |
|||
F 0 "#PWR0107" H 3450 3000 50 0001 C CNN |
|||
F 1 "VCC" H 3467 3323 50 0000 C CNN |
|||
F 2 "" H 3450 3150 50 0001 C CNN |
|||
F 3 "" H 3450 3150 50 0001 C CNN |
|||
1 3450 3150 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
Wire Wire Line |
|||
3850 1750 3850 1800 |
|||
Wire Wire Line |
|||
2750 3150 2750 3200 |
|||
Wire Wire Line |
|||
2750 3200 2900 3200 |
|||
Wire Wire Line |
|||
3200 3200 3300 3200 |
|||
Wire Wire Line |
|||
3450 3200 3450 3150 |
|||
Wire Wire Line |
|||
3450 3200 3450 3300 |
|||
Connection ~ 3450 3200 |
|||
Wire Wire Line |
|||
2800 3300 2750 3300 |
|||
Connection ~ 2750 3200 |
|||
Wire Wire Line |
|||
2950 2200 3000 2200 |
|||
Wire Wire Line |
|||
3000 2200 3000 2150 |
|||
Wire Wire Line |
|||
2950 2500 3000 2500 |
|||
Wire Wire Line |
|||
3000 2500 3000 2550 |
|||
Wire Wire Line |
|||
2950 2400 3050 2400 |
|||
Wire Wire Line |
|||
3050 2400 3050 2500 |
|||
Wire Wire Line |
|||
3050 2500 3150 2500 |
|||
Wire Wire Line |
|||
3150 2500 3150 2450 |
|||
Wire Wire Line |
|||
3150 2250 3150 2200 |
|||
Wire Wire Line |
|||
3150 2200 3050 2200 |
|||
Wire Wire Line |
|||
3050 2200 3050 2300 |
|||
Wire Wire Line |
|||
3050 2300 2950 2300 |
|||
Wire Wire Line |
|||
3450 2200 3150 2200 |
|||
Connection ~ 3150 2200 |
|||
Wire Wire Line |
|||
3450 2500 3150 2500 |
|||
Connection ~ 3150 2500 |
|||
$Comp |
|||
L power:VCC #PWR0108 |
|||
U 1 1 5C069637 |
|||
P 4150 3150 |
|||
F 0 "#PWR0108" H 4150 3000 50 0001 C CNN |
|||
F 1 "VCC" H 4300 3200 50 0000 C CNN |
|||
F 2 "" H 4150 3150 50 0001 C CNN |
|||
F 3 "" H 4150 3150 50 0001 C CNN |
|||
1 4150 3150 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
$Comp |
|||
L power:GND #PWR0109 |
|||
U 1 1 5C069650 |
|||
P 4150 3550 |
|||
F 0 "#PWR0109" H 4150 3300 50 0001 C CNN |
|||
F 1 "GND" H 4155 3377 50 0001 C CNN |
|||
F 2 "" H 4150 3550 50 0001 C CNN |
|||
F 3 "" H 4150 3550 50 0001 C CNN |
|||
1 4150 3550 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
Wire Wire Line |
|||
4150 3150 4150 3200 |
|||
Wire Wire Line |
|||
4150 3450 4150 3500 |
|||
$Comp |
|||
L power:GND #PWR0110 |
|||
U 1 1 5C06A0D9 |
|||
P 3850 2950 |
|||
F 0 "#PWR0110" H 3850 2700 50 0001 C CNN |
|||
F 1 "GND" H 3855 2777 50 0001 C CNN |
|||
F 2 "" H 3850 2950 50 0001 C CNN |
|||
F 3 "" H 3850 2950 50 0001 C CNN |
|||
1 3850 2950 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
Wire Wire Line |
|||
3850 2900 3850 2950 |
|||
$Comp |
|||
L power:GND #PWR0111 |
|||
U 1 1 5C06A85A |
|||
P 4300 2550 |
|||
F 0 "#PWR0111" H 4300 2300 50 0001 C CNN |
|||
F 1 "GND" H 4305 2377 50 0001 C CNN |
|||
F 2 "" H 4300 2550 50 0001 C CNN |
|||
F 3 "" H 4300 2550 50 0001 C CNN |
|||
1 4300 2550 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
Wire Wire Line |
|||
4250 2400 4300 2400 |
|||
Wire Wire Line |
|||
4300 2400 4300 2500 |
|||
Wire Wire Line |
|||
4300 2500 4250 2500 |
|||
Wire Wire Line |
|||
4300 2300 4300 2400 |
|||
Wire Wire Line |
|||
4300 2300 4250 2300 |
|||
Connection ~ 4300 2400 |
|||
Wire Wire Line |
|||
4300 2500 4300 2550 |
|||
Connection ~ 4300 2500 |
|||
$Comp |
|||
L power:VCC #PWR0112 |
|||
U 1 1 5C06BD25 |
|||
P 4600 2050 |
|||
F 0 "#PWR0112" H 4600 1900 50 0001 C CNN |
|||
F 1 "VCC" H 4750 2100 50 0000 C CNN |
|||
F 2 "" H 4600 2050 50 0001 C CNN |
|||
F 3 "" H 4600 2050 50 0001 C CNN |
|||
1 4600 2050 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
$Comp |
|||
L power:GND #PWR0113 |
|||
U 1 1 5C06CC4B |
|||
P 4600 2350 |
|||
F 0 "#PWR0113" H 4600 2100 50 0001 C CNN |
|||
F 1 "GND" H 4605 2177 50 0001 C CNN |
|||
F 2 "" H 4600 2350 50 0001 C CNN |
|||
F 3 "" H 4600 2350 50 0001 C CNN |
|||
1 4600 2350 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
Wire Wire Line |
|||
4650 2200 4500 2200 |
|||
Wire Wire Line |
|||
4650 2100 4600 2100 |
|||
Wire Wire Line |
|||
4600 2100 4600 2050 |
|||
Wire Wire Line |
|||
4650 2300 4600 2300 |
|||
Wire Wire Line |
|||
4600 2300 4600 2350 |
|||
$Comp |
|||
L Device:R_Small R2 |
|||
U 1 1 5C06E1D6 |
|||
P 4400 2200 |
|||
F 0 "R2" V 4296 2200 50 0000 C CNN |
|||
F 1 "R_Small" V 4295 2200 50 0001 C CNN |
|||
F 2 "Resistor_SMD:R_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 4400 2200 50 0001 C CNN |
|||
F 3 "~" H 4400 2200 50 0001 C CNN |
|||
1 4400 2200 |
|||
0 1 1 0 |
|||
$EndComp |
|||
Wire Wire Line |
|||
4250 2200 4300 2200 |
|||
$Comp |
|||
L power:PWR_FLAG #FLG0101 |
|||
U 1 1 5C07179E |
|||
P 2900 3150 |
|||
F 0 "#FLG0101" H 2900 3225 50 0001 C CNN |
|||
F 1 "PWR_FLAG" H 2900 3324 50 0001 C CNN |
|||
F 2 "" H 2900 3150 50 0001 C CNN |
|||
F 3 "~" H 2900 3150 50 0001 C CNN |
|||
1 2900 3150 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
$Comp |
|||
L power:PWR_FLAG #FLG0102 |
|||
U 1 1 5C071EE6 |
|||
P 3300 3150 |
|||
F 0 "#FLG0102" H 3300 3225 50 0001 C CNN |
|||
F 1 "PWR_FLAG" H 3300 3324 50 0001 C CNN |
|||
F 2 "" H 3300 3150 50 0001 C CNN |
|||
F 3 "~" H 3300 3150 50 0001 C CNN |
|||
1 3300 3150 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
Wire Wire Line |
|||
3300 3150 3300 3200 |
|||
Connection ~ 3300 3200 |
|||
Wire Wire Line |
|||
3300 3200 3450 3200 |
|||
Wire Wire Line |
|||
2900 3150 2900 3200 |
|||
Connection ~ 2900 3200 |
|||
Wire Wire Line |
|||
2900 3200 3000 3200 |
|||
Wire Wire Line |
|||
2750 3200 2750 3300 |
|||
$Comp |
|||
L power:PWR_FLAG #FLG0103 |
|||
U 1 1 5C07505B |
|||
P 3350 3600 |
|||
F 0 "#FLG0103" H 3350 3675 50 0001 C CNN |
|||
F 1 "PWR_FLAG" H 3350 3774 50 0001 C CNN |
|||
F 2 "" H 3350 3600 50 0001 C CNN |
|||
F 3 "~" H 3350 3600 50 0001 C CNN |
|||
1 3350 3600 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
Wire Wire Line |
|||
3400 3300 3450 3300 |
|||
Wire Wire Line |
|||
3100 3700 3100 3650 |
|||
Wire Wire Line |
|||
3350 3600 3350 3700 |
|||
Wire Wire Line |
|||
3350 3700 3100 3700 |
|||
Connection ~ 3100 3700 |
|||
$Comp |
|||
L Device:C_Small C2 |
|||
U 1 1 5C07E1E5 |
|||
P 4400 3350 |
|||
F 0 "C2" H 4492 3396 50 0000 L CNN |
|||
F 1 "C_Small" H 4492 3305 50 0001 L CNN |
|||
F 2 "Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.40mm_HandSolder" H 4400 3350 50 0001 C CNN |
|||
F 3 "~" H 4400 3350 50 0001 C CNN |
|||
1 4400 3350 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
Wire Wire Line |
|||
4150 3200 4400 3200 |
|||
Wire Wire Line |
|||
4400 3200 4400 3250 |
|||
Connection ~ 4150 3200 |
|||
Wire Wire Line |
|||
4150 3200 4150 3250 |
|||
Wire Wire Line |
|||
4400 3450 4400 3500 |
|||
Wire Wire Line |
|||
4400 3500 4150 3500 |
|||
Connection ~ 4150 3500 |
|||
Wire Wire Line |
|||
4150 3500 4150 3550 |
|||
$Comp |
|||
L Device:CP_Small C3 |
|||
U 1 1 5C07F5DF |
|||
P 4600 3350 |
|||
F 0 "C3" H 4688 3396 50 0000 L CNN |
|||
F 1 "CP_Small" H 4688 3305 50 0000 L CNN |
|||
F 2 "Capacitor_SMD:CP_Elec_3x5.4" H 4600 3350 50 0001 C CNN |
|||
F 3 "~" H 4600 3350 50 0001 C CNN |
|||
1 4600 3350 |
|||
1 0 0 -1 |
|||
$EndComp |
|||
Wire Wire Line |
|||
4400 3200 4600 3200 |
|||
Wire Wire Line |
|||
4600 3200 4600 3250 |
|||
Connection ~ 4400 3200 |
|||
Wire Wire Line |
|||
4600 3450 4600 3500 |
|||
Wire Wire Line |
|||
4600 3500 4400 3500 |
|||
Connection ~ 4400 3500 |
|||
Text Label 3300 2200 0 50 ~ 0 |
|||
D+ |
|||
Text Label 3300 2500 0 50 ~ 0 |
|||
D- |
|||
$EndSCHEMATC |
@ -0,0 +1,33 @@ |
|||
update=22/05/2015 07:44:53 |
|||
version=1 |
|||
last_client=kicad |
|||
[general] |
|||
version=1 |
|||
RootSch= |
|||
BoardNm= |
|||
[pcbnew] |
|||
version=1 |
|||
LastNetListRead= |
|||
UseCmpFile=1 |
|||
PadDrill=0.600000000000 |
|||
PadDrillOvalY=0.600000000000 |
|||
PadSizeH=1.500000000000 |
|||
PadSizeV=1.500000000000 |
|||
PcbTextSizeV=1.500000000000 |
|||
PcbTextSizeH=1.500000000000 |
|||
PcbTextThickness=0.300000000000 |
|||
ModuleTextSizeV=1.000000000000 |
|||
ModuleTextSizeH=1.000000000000 |
|||
ModuleTextSizeThickness=0.150000000000 |
|||
SolderMaskClearance=0.000000000000 |
|||
SolderMaskMinWidth=0.000000000000 |
|||
DrawSegmentWidth=0.200000000000 |
|||
BoardOutlineThickness=0.100000000000 |
|||
ModuleOutlineThickness=0.150000000000 |
|||
[cvpcb] |
|||
version=1 |
|||
NetIExt=net |
|||
[eeschema] |
|||
version=1 |
|||
LibDir= |
|||
[eeschema/libraries] |
Before Width: | Height: | Size: 424 KiB After Width: | Height: | Size: 380 KiB |
Before Width: | Height: | Size: 371 KiB After Width: | Height: | Size: 378 KiB |
After Width: | Height: | Size: 1.1 MiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 206 KiB |
Before Width: | Height: | Size: 721 KiB After Width: | Height: | Size: 696 KiB |
After Width: | Height: | Size: 445 KiB |
After Width: | Height: | Size: 157 KiB |
@ -0,0 +1,44 @@ |
|||
EESchema-LIBRARY Version 2.4 |
|||
#encoding utf-8 |
|||
# |
|||
# MAX481E |
|||
# |
|||
DEF MAX481E U 0 20 Y Y 1 F N |
|||
F0 "U" -240 450 50 H V C CNN |
|||
F1 "MAX481E" 30 450 50 H V L CNN |
|||
F2 "" 0 -700 50 H I C CNN |
|||
F3 "" 0 50 50 H I C CNN |
|||
ALIAS MAX483E MAX485E MAX487E MAX1487E MAX3485 MAX3483 MAX3486 |
|||
$FPLIST |
|||
DIP*W7.62mm* |
|||
SOIC*3.9x4.9mm*P1.27mm* |
|||
$ENDFPLIST |
|||
DRAW |
|||
C -12 -145 14 0 1 10 F |
|||
C -1 59 14 0 1 10 F |
|||
C 65 75 14 0 1 10 F |
|||
S -300 400 300 -500 0 1 10 f |
|||
S 50 125 50 125 0 1 0 N |
|||
P 2 0 1 10 -160 -200 -75 -200 N |
|||
P 2 0 1 10 -160 100 -50 100 N |
|||
P 2 0 1 10 -50 -126 -50 -136 N |
|||
P 2 0 1 10 -25 -200 210 -200 N |
|||
P 3 0 1 10 -160 -100 -50 -100 -50 -125 N |
|||
P 3 0 1 10 0 50 0 0 -160 0 N |
|||
P 3 0 1 10 50 125 150 125 150 -200 N |
|||
P 3 0 1 10 100 75 100 -150 0 -150 N |
|||
P 4 0 1 10 -75 -125 -75 -225 25 -175 -75 -125 N |
|||
P 4 0 1 10 -50 100 50 150 50 50 -50 100 N |
|||
P 4 0 1 10 75 75 175 75 175 100 210 100 N |
|||
X RO 1 -400 100 100 R 50 50 1 1 O |
|||
X ~RE 2 -400 0 100 R 50 50 1 1 I |
|||
X DE 3 -400 -100 100 R 50 50 1 1 I |
|||
X DI 4 -400 -200 100 R 50 50 1 1 I |
|||
X GND 5 0 -600 100 U 50 50 1 1 W |
|||
X A 6 400 -200 100 L 50 50 1 1 B |
|||
X B 7 400 100 100 L 50 50 1 1 B |
|||
X VCC 8 0 500 100 D 50 50 1 1 W |
|||
ENDDRAW |
|||
ENDDEF |
|||
# |
|||
#End Library |
@ -0,0 +1,29 @@ |
|||
EESchema-LIBRARY Version 2.4 |
|||
#encoding utf-8 |
|||
# |
|||
# PCA9306 |
|||
# |
|||
DEF PCA9306 U 0 40 Y Y 1 F N |
|||
F0 "U" -300 450 50 H V L CNN |
|||
F1 "PCA9306" 200 450 50 H V L CNN |
|||
F2 "" -400 350 50 H I C CNN |
|||
F3 "" -300 450 50 H I C CNN |
|||
$FPLIST |
|||
SSOP*2.95x2.8mm*P0.65mm* |
|||
VSSOP*2.3x2mm*P0.5mm* |
|||
X2SON*1.4x1mm*P0.35mm* |
|||
$ENDFPLIST |
|||
DRAW |
|||
S -300 400 300 -400 0 1 10 f |
|||
X GND 1 0 -500 100 U 50 50 1 1 W |
|||
X VREF1 2 -100 500 100 D 50 50 1 1 W |
|||
X SCL1 3 -400 -100 100 R 50 50 1 1 B |
|||
X SDA1 4 -400 0 100 R 50 50 1 1 B |
|||
X SDA2 5 400 0 100 L 50 50 1 1 B |
|||
X SCL2 6 400 -100 100 L 50 50 1 1 B |
|||
X VREF2 7 100 500 100 D 50 50 1 1 W |
|||
X EN 8 400 100 100 L 50 50 1 1 I |
|||
ENDDRAW |
|||
ENDDEF |
|||
# |
|||
#End Library |
@ -0,0 +1,109 @@ |
|||
#!/usr/bin/env python3 |
|||
|
|||
from __future__ import absolute_import, print_function |
|||
|
|||
import sys |
|||
import argparse |
|||
import socket |
|||
from datetime import datetime |
|||
|
|||
import can |
|||
from can import Bus, BusState, Logger |
|||
|
|||
import paho.mqtt.client as mqtt |
|||
|
|||
sub_topic = "coil" |
|||
coil_map = { |
|||
'EZ': [ 0x03, 0x01 ], |
|||
'K': [ 0x03, 0x02 ], |
|||
'WZ1': [ 0x02, 0x01 ], |
|||
'WZ2': [ 0x02, 0x02 ], |
|||
'TER': [ 0x03, 0x03 ], |
|||
'FE': [ 0x03, 0x07 ], |
|||
'TRE': [ 0x02, 0x03 ], |
|||
'FO': [ 0x01, 0x03 ], |
|||
'TRO': [ 0x01, 0x07 ], |
|||
'KI1': [ 0x01, 0x06 ], |
|||
'KI2': [ 0x01, 0x04 ], |
|||
'SCH': [ 0x01, 0x08 ], |
|||
'B1': [ 0x01, 0x01 ], |
|||
'B2': [ 0x01, 0x02 ], |
|||
'ROL_EZ_G_DOWN': [0x03, 0x05], |
|||
'ROL_EZ_G_UP': [0x03,0x04], |
|||
'ROL_EZ_N_DOWN': [0x03, 0x06], |
|||
'ROL_EZ_N_UP': [0x03,0x08], |
|||
'EG1': [ 0x02, 0x09 ], |
|||
'EG2': [ 0x03, 0x09 ], |
|||
'OG': [ 0x01, 0x09 ], |
|||
'ALL': [ 0xFF, 0x09 ], |
|||
} |
|||
|
|||
cmd_map = { |
|||
'off': 0, |
|||
'0': 0, |
|||
'on': 1, |
|||
'1': 1, |
|||
'value': 2, |
|||
'toggle': 3 |
|||
} |
|||
|
|||
|
|||
def decon(msg_id): |
|||
msg_prio=msg_id>>26 |
|||
msg_type=(msg_id>>24) & 0x03 |
|||
msg_dst=(msg_id>>16) & 0xFF |
|||
msg_src=(msg_id>>8) & 0xFF |
|||
msg_cmd=msg_id & 0xFF |
|||
# print("msg_id: ", hex(msg_id), "prio: ", hex(msg_prio),"type: ", hex(msg_type)," dst: ", hex(msg_dst)," src: ", hex(msg_src)," cmd: ",hex(msg_cmd)) |
|||
return [msg_prio, msg_type, msg_dst, msg_src, msg_cmd] |
|||
|
|||
def con(msg_dst,msg_cmd,msg_prio=3,msg_type=0,msg_src=11, ): |
|||
msg_id=(msg_prio<<26) + \ |
|||
((msg_type&0x03)<<24) +\ |
|||
((msg_dst&0xFF)<<16) +\ |
|||
((msg_src&0xFF)<<8) +\ |
|||
(msg_cmd&0xFF) |
|||
print("Constructed ID: "+hex(msg_id)) |
|||
return msg_id |
|||
|
|||
def on_connect(mcp_mqtt, userdata, flags, rc): |
|||
print("Connected with result code "+str(rc)) |
|||
mcp_mqtt.subscribe(sub_topic+"/+") |
|||
|
|||
|
|||
def main(): |
|||
can_filters = [] |
|||
config = {"can_filters": can_filters, "single_handle": True} |
|||
config["interface"] = "socketcan_native" |
|||
config["bitrate"] = 125000 |
|||
canbus = can.Bus("can1", **config) |
|||
# canBuffer= canbus.BufferedReader() |
|||
print('Connected to {}: {}'.format(canbus.__class__.__name__, canbus.channel_info)) |
|||
print('Can Logger (Started on {})\n'.format(datetime.now())) |
|||
|
|||
mcp_mqtt = mqtt.Client() |
|||
mcp_mqtt.on_connect = on_connect |
|||
mcp_mqtt.user_data_set(canbus) |
|||
mcp_mqtt.connect("mcp", 1883, 60) |
|||
|
|||
mcp_mqtt.publish("coil/welcome", "1" , retain=0) |
|||
try: |
|||
while True: |
|||
msg = canbus.recv(1) |
|||
# msg = canBuffer.get_message() |
|||
if msg is not None: |
|||
de=decon(msg.arbitration_id) |
|||
m= { "prio": hex(de[0]), "type": hex(de[1]), "dst": hex(de[2]), "src": hex(de[3]), "cmd": hex(de[4]), "action": hex(msg.data[0]) } |
|||
if de[2]==0 and de[4] == 6: |
|||
print("received state: ", hex(de[3]), hex(msg.data[0]), hex(msg.data[1])) |
|||
for key, address in coil_map.items(): |
|||
if address[0] == de[3] and address[1] == msg.data[0]+1: |
|||
print("coil/"+key+" changed to "+str(msg.data[1])) |
|||
mcp_mqtt.publish("coil/"+key+"/state", msg.data[1] , retain=1) |
|||
except KeyboardInterrupt: |
|||
pass |
|||
finally: |
|||
canbus.shutdown() |
|||
|
|||
if __name__ == "__main__": |
|||
main() |
@ -0,0 +1,85 @@ |
|||
#!/usr/bin/env python3 |
|||
from __future__ import absolute_import, print_function |
|||
|
|||
import sys |
|||
import argparse |
|||
import socket |
|||
from datetime import datetime |
|||
|
|||
import can |
|||
from can import Bus, BusState, Logger |
|||
|
|||
import paho.mqtt.client as mqtt |
|||
|
|||
def decon(msg_id): |
|||
msg_prio=msg_id>>26 |
|||
msg_type=(msg_id>>24) & 0x03 |
|||
msg_dst=(msg_id>>16) & 0xFF |
|||
msg_src=(msg_id>>8) & 0xFF |
|||
msg_cmd=msg_id & 0xFF |
|||
print("prio: ", hex(msg_prio),"type: ", hex(msg_type)," dst: ", hex(msg_dst)," src: ", hex(msg_src)," cmd: ",hex(msg_cmd)) |
|||
return [msg_prio, msg_type, msg_dst, msg_src, msg_cmd] |
|||
|
|||
def on_connect(mcp_mqtt, userdata, flags, rc): |
|||
print("Connected with result code "+str(rc)) |
|||
|
|||
# Subscribing in on_connect() means that if we lose the connection and |
|||
# reconnect then subscriptions will be renewed. |
|||
mcp_mqtt.subscribe("can/raw") |
|||
mcp_mqtt.subscribe("ctest/#") |
|||
|
|||
def on_message(mcp_mqtt, userdata, msg): |
|||
local_bus=userdata |
|||
topic=msg.topic |
|||
print("data Received topic: ", topic) |
|||
m_decode=str(msg.payload.decode("utf-8","ignore")) |
|||
print("data Received",m_decode) |
|||
msg_id=int(m_decode.split('#')[0],16) |
|||
|
|||
msg_data=int(m_decode.split('#')[1],16) |
|||
print(msg_data) |
|||
m = can.Message(arbitration_id=msg_id, |
|||
data=[msg_data], |
|||
extended_id=True) |
|||
try: |
|||
local_bus.send(m) |
|||
except BaseException as e: |
|||
logging.error("Error sending can message {%s}: %s" % (m, e)) |
|||
print("data sent to CAN",m) |
|||
def main(): |
|||
verbosity = 2 |
|||
|
|||
logging_level_name = ['critical', 'error', 'warning', 'info', 'debug', 'subdebug'][min(5, verbosity)] |
|||
can.set_logging_level(logging_level_name) |
|||
|
|||
can_filters = [] |
|||
config = {"can_filters": can_filters, "single_handle": True} |
|||
config["interface"] = "socketcan" |
|||
config["bitrate"] = 125000 |
|||
bus = Bus("can1", **config) |
|||
|
|||
print('Connected to {}: {}'.format(bus.__class__.__name__, bus.channel_info)) |
|||
print('Can Logger (Started on {})\n'.format(datetime.now())) |
|||
|
|||
mcp_mqtt = mqtt.Client() |
|||
mcp_mqtt.on_connect = on_connect |
|||
mcp_mqtt.on_message = on_message |
|||
mcp_mqtt.user_data_set(bus) |
|||
mcp_mqtt.connect("mcp", 1883, 60) |
|||
|
|||
try: |
|||
while True: |
|||
mcp_mqtt.loop_start() |
|||
msg = bus.recv(1) |
|||
if msg is not None: |
|||
de=decon(msg.arbitration_id) |
|||
m= { "prio": hex(de[0]), "type": hex(de[1]), "dst": hex(de[2]), "src": hex(de[3]), "cmd": hex(de[4]), "data": "".join("%02x" % b for b in msg.data) } |
|||
print(m) |
|||
mcp_mqtt.publish("can/rx", str(m)) |
|||
except KeyboardInterrupt: |
|||
pass |
|||
finally: |
|||
bus.shutdown() |
|||
|
|||
if __name__ == "__main__": |
|||
main() |
@ -0,0 +1,63 @@ |
|||
#!/usr/bin/env python3 |
|||
# coding: utf-8 |
|||
|
|||
|
|||
from __future__ import absolute_import, print_function |
|||
|
|||
import sys |
|||
import argparse |
|||
import socket |
|||
from datetime import datetime |
|||
|
|||
import can |
|||
from can import Bus, BusState, Logger |
|||
|
|||
|
|||
def decon(msg_id): |
|||
msg_prio=msg_id>>26 |
|||
msg_type=(msg_id>>24) & 0x03 |
|||
msg_dst=(msg_id>>16) & 0xFF |
|||
msg_src=(msg_id>>8) & 0xFF |
|||
msg_cmd=msg_id & 0xFF |
|||
print("prio: ", hex(msg_prio),"type: ", hex(msg_type)," dst: ", hex(msg_dst)," src: ", hex(msg_src)," cmd: ",hex(msg_cmd)) |
|||
return [msg_prio, msg_type, msg_dst, msg_src, msg_cmd] |
|||
|
|||
|
|||
def main(): |
|||
verbosity = 2 |
|||
|
|||
logging_level_name = ['critical', 'error', 'warning', 'info', 'debug', 'subdebug'][min(5, verbosity)] |
|||
can.set_logging_level(logging_level_name) |
|||
|
|||
can_filters = [] |
|||
config = {"can_filters": can_filters, "single_handle": True} |
|||
config["interface"] = "socketcan" |
|||
config["bitrate"] = 125000 |
|||
bus = Bus("can1", **config) |
|||
|
|||
print('Connected to {}: {}'.format(bus.__class__.__name__, bus.channel_info)) |
|||
print('Can Logger (Started on {})\n'.format(datetime.now())) |
|||
|
|||
try: |
|||
while True: |
|||
msg = bus.recv(1) |
|||
if msg is not None: |
|||
de=decon(msg.arbitration_id) |
|||
m= { "prio": hex(de[0]), "type": hex(de[1]), "dst": hex(de[2]), "src": hex(de[3]), "cmd": hex(de[4]), "target": hex(msg.data[0]) } |
|||
if de[2] is 3 and msg.data[0] is 3 and de[1] is 0 and de[3] is 3 and de[4] is 3 : |
|||
print(m) |
|||
m = can.Message(arbitration_id=0x0C030900, |
|||
data=[3], |
|||
extended_id=True) |
|||
try: |
|||
bus.send(m) |
|||
except BaseException as e: |
|||
logging.error("Error sending can message {%s}: %s" % (m, e)) |
|||
|
|||
except KeyboardInterrupt: |
|||
pass |
|||
finally: |
|||
bus.shutdown() |
|||
|
|||
if __name__ == "__main__": |
|||
main() |
@ -0,0 +1,163 @@ |
|||
#!/usr/bin/env python3 |
|||
|
|||
from __future__ import absolute_import, print_function |
|||
|
|||
import sys |
|||
import argparse |
|||
import socket |
|||
from datetime import datetime |
|||
|
|||
import can |
|||
from can import Bus, BusState, Logger |
|||
|
|||
import paho.mqtt.client as mqtt |
|||
|
|||
sub_topic = "coil" |
|||
coil_map = { |
|||
'EZ': [ 0x03, 0x01 ], |
|||
'K': [ 0x03, 0x02 ], |
|||
'WZ1': [ 0x02, 0x01 ], |
|||
'WZ2': [ 0x02, 0x02 ], |
|||
'TER': [ 0x03, 0x03 ], |
|||
'FE': [ 0x03, 0x07 ], |
|||
'TRE': [ 0x02, 0x03 ], |
|||
'FO': [ 0x01, 0x03 ], |
|||
'TRO': [ 0x01, 0x07 ], |
|||
'KI1': [ 0x01, 0x06 ], |
|||
'KI2': [ 0x01, 0x04 ], |
|||
'SCH': [ 0x01, 0x08 ], |
|||
'B1': [ 0x01, 0x01 ], |
|||
'B2': [ 0x01, 0x02 ], |
|||
'ROL_EZ_G_DOWN': [0x03, 0x05, -1], |
|||
'ROL_EZ_G_UP': [0x03,0x04, -1], |
|||
'ROL_EZ_N_DOWN': [0x03, 0x06, -2], |
|||
'ROL_EZ_N_UP': [0x03,0x08, -2], |
|||
'EG1': [ 0x02, 0x09 ], |
|||
'EG2': [ 0x03, 0x09 ], |
|||
'OG': [ 0x01, 0x09 ], |
|||
'ALL': [ 0xFF, 0x09 ], |
|||
} |
|||
|
|||
cmd_map = { |
|||
'off': 0, |
|||
'0': 0, |
|||
'on': 1, |
|||
'1': 1, |
|||
'value': 2, |
|||
'toggle': 3 |
|||
} |
|||
|
|||
|
|||
def decon(msg_id): |
|||
msg_prio=msg_id>>26 |
|||
msg_type=(msg_id>>24) & 0x03 |
|||
msg_dst=(msg_id>>16) & 0xFF |
|||
msg_src=(msg_id>>8) & 0xFF |
|||
msg_cmd=msg_id & 0xFF |
|||
# print("msg_id: ", hex(msg_id), "prio: ", hex(msg_prio),"type: ", hex(msg_type)," dst: ", hex(msg_dst)," src: ", hex(msg_src)," cmd: ",hex(msg_cmd)) |
|||
return [msg_prio, msg_type, msg_dst, msg_src, msg_cmd] |
|||
|
|||
def con(msg_dst,msg_cmd,msg_prio=3,msg_type=0,msg_src=11, ): |
|||
msg_id=(msg_prio<<26) + \ |
|||
((msg_type&0x03)<<24) +\ |
|||
((msg_dst&0xFF)<<16) +\ |
|||
((msg_src&0xFF)<<8) +\ |
|||
(msg_cmd&0xFF) |
|||
print("Constructed ID: "+hex(msg_id)) |
|||
return msg_id |
|||
|
|||
def on_connect(mcp_mqtt, userdata, flags, rc): |
|||
print("Connected with result code "+str(rc)) |
|||
|
|||
# Subscribing in on_connect() means that if we lose the connection and |
|||
# reconnect then subscriptions will be renewed. |
|||
mcp_mqtt.subscribe(sub_topic+"/+") |
|||
print("Subscribed to:"+sub_topic+"/+") |
|||
|
|||
def on_message(mcp_mqtt, userdata, msg): |
|||
local_bus=userdata |
|||
print("data Received topic: ", msg.topic) |
|||
m_decode=str(msg.payload.decode("utf-8","ignore")) |
|||
print("data Received",m_decode) |
|||
msg_cmd=cmd_map[m_decode] |
|||
sub=msg.topic[len(sub_topic)+1:] |
|||
coil=sub |
|||
print("substring: "+coil) |
|||
addr = coil_map[coil] |
|||
print("Addr:", addr) |
|||
if msg_cmd == 2: |
|||
msg_data.append(value) |
|||
print("msg_cmd",msg_cmd, len(addr)) |
|||
if msg_cmd is not 0 and len(addr) is 3: |
|||
print("hello 001") |
|||
for key, value in coil_map.items(): |
|||
print("checking: ", key) |
|||
if len(value) is 3: |
|||
print("value_2 is", value[2], "Addr: ", addr[2]) |
|||
if value[2] is addr[2]: |
|||
msg_id=con(msg_dst=value[0],msg_cmd=0) |
|||
msg_data=[value[1]] |
|||
m = can.Message(arbitration_id=msg_id, |
|||
data=msg_data, |
|||
extended_id=True) |
|||
try: |
|||
local_bus.send(m) |
|||
except BaseException as e: |
|||
logging.error("Error sending can message {%s}: %s" % (m, e)) |
|||
print("data sent to CAN",m) |
|||
|
|||
msg_id=con(msg_dst=addr[0],msg_cmd=msg_cmd) |
|||
msg_data=[addr[1]] |
|||
|
|||
m = can.Message(arbitration_id=msg_id, |
|||
data=msg_data, |
|||
extended_id=True) |
|||
try: |
|||
local_bus.send(m) |
|||
except BaseException as e: |
|||
logging.error("Error sending can message {%s}: %s" % (m, e)) |
|||
print("data sent to CAN",m) |
|||
|
|||
|
|||
def main(): |
|||
verbosity = 2 |
|||
|
|||
logging_level_name = ['critical', 'error', 'warning', 'info', 'debug', 'subdebug'][min(5, verbosity)] |
|||
can.set_logging_level(logging_level_name) |
|||
|
|||
can_filters = [] |
|||
config = {"can_filters": can_filters, "single_handle": True} |
|||
config["interface"] = "socketcan" |
|||
config["bitrate"] = 125000 |
|||
bus = Bus("can1", **config) |
|||
|
|||
print('Connected to {}: {}'.format(bus.__class__.__name__, bus.channel_info)) |
|||
print('Can Logger (Started on {})\n'.format(datetime.now())) |
|||
|
|||
mcp_mqtt = mqtt.Client() |
|||
mcp_mqtt.on_connect = on_connect |
|||
mcp_mqtt.on_message = on_message |
|||
mcp_mqtt.user_data_set(bus) |
|||
mcp_mqtt.connect("mcp", 1883, 60) |
|||
mcp_mqtt.loop_start() |
|||
|
|||
try: |
|||
while True: |
|||
msg = bus.recv(1) |
|||
if msg is not None: |
|||
de=decon(msg.arbitration_id) |
|||
m= { "prio": hex(de[0]), "type": hex(de[1]), "dst": hex(de[2]), "src": hex(de[3]), "cmd": hex(de[4]), "action": hex(msg.data[0]) } |
|||
if de[2]==0 and de[4] == 6: |
|||
print("received state: ", hex(de[3]), hex(msg.data[0]), hex(msg.data[1])) |
|||
for key in coil_map: |
|||
address=coil_map[key] |
|||
if address[0] == de[3] and address[1] == msg.data[0]+1: |
|||
print("coil/"+key+" changed to "+str(msg.data[1])) |
|||
mcp_mqtt.publish("coil/"+key+"/state", msg.data[1] , retain=1) |
|||
except KeyboardInterrupt: |
|||
pass |
|||
finally: |
|||
bus.shutdown() |
|||
|
|||
if __name__ == "__main__": |
|||
main() |
@ -0,0 +1,41 @@ |
|||
#! /usr/bin/env python |
|||
import sys |
|||
|
|||
msg_id=int(str(sys.argv[1]),0) & 0x1FFFFFFF |
|||
msg_prio=msg_id>>26 |
|||
msg_type=(msg_id>>24) & 0x03 |
|||
msg_dst=(msg_id>>16) & 0xFF |
|||
msg_src=(msg_id>>8) & 0xFF |
|||
msg_cmd=msg_id & 0xFF |
|||
|
|||
#print('id: {0:b}'.format(msg_id)) |
|||
print('id: {0:#010x} {0:#031b}'.format(msg_id ,msg_id)) |
|||
#print("id:", hex(msg_id), format(40,str(bin(msg_id)))) |
|||
|
|||
print('prio: {0:#03x} {0:#04b}'.format(msg_prio)) |
|||
print('type: {0:#03x} {0:#04b}'.format(msg_type)) |
|||
print('dst: {0:#04x} {0:#010b}'.format(msg_dst)) |
|||
print('src: {0:#04x} {0:#010b}'.format(msg_src)) |
|||
print('cmd: {0:#04x} {0:#010b}'.format(msg_cmd)) |
|||
|
|||
|
|||
nmsg_prio=msg_id>>26 |
|||
nmsg_type=(msg_id>>24) & 0x03 |
|||
nmsg_src=(msg_id>>18) & 0x3F |
|||
nmsg_dst=(msg_id>>12) & 0x3F |
|||
nmsg_targ=(msg_id>>6) & 0x3F |
|||
nmsg_cmd=msg_id & 0x1F |
|||
|
|||
|
|||
print('New schema') |
|||
|
|||
#print('id: {0:b}'.format(msg_id)) |
|||
print('id: {0:#010x} {0:#031b}'.format(msg_id)) |
|||
#print("id:", hex(msg_id), format(40,str(bin(msg_id)))) |
|||
|
|||
print('prio: {0:#04x} {0:#04b}'.format(nmsg_prio)) |
|||
print('type: {0:#04x} {0:#04b}'.format(nmsg_type)) |
|||
print('src: {0:#04x} {0:#08b}'.format(nmsg_src)) |
|||
print('dst: {0:#04x} {0:#08b}'.format(nmsg_dst)) |
|||
print('target: {0:#04x} {0:#08b}'.format(nmsg_targ)) |
|||
print('cmd: {0:#04x} {0:#07b}'.format(nmsg_cmd)) |
@ -0,0 +1,170 @@ |
|||
#!/usr/bin/env python3 |
|||
|
|||
from __future__ import absolute_import, print_function |
|||
|
|||
import sys |
|||
import argparse |
|||
import socket |
|||
from datetime import datetime |
|||
|
|||
import can |
|||
from can import Bus, BusState, Logger |
|||
|
|||
import paho.mqtt.client as mqtt |
|||
|
|||
sub_topic = "light" |
|||
aliases = { |
|||
'Esszimmer': 'EZ', |
|||
'Esszimmer oben': 'EZ', |
|||
'Küche': 'K', |
|||
'Wohnzimmer1': 'WZ1', |
|||
'Wohnzimmer2': 'WZ2', |
|||
'Wohnzimmer Nord': 'WZ1', |
|||
'Wohnzimmer Süd': 'WZ2', |
|||
'Wohnzimmer Tür': 'WZ1', |
|||
'Wohnzimmer TV': 'WZ2', |
|||
'Wohnzimmer Fernseher': 'WZ2', |
|||
'Bad Decke': 'B1', |
|||
'Bad Spiegel': 'B2', |
|||
'Bjarne': 'K1', |
|||
'Inka': 'K2', |
|||
'Schlafzimmer': 'SCH', |
|||
'Flur EG': 'FE', |
|||
'Flur unten': 'FE', |
|||
'Flur OG': 'FO', |
|||
'Flur oben': 'FO', |
|||
'Treppe EG': 'TRE', |
|||
'Treppe unten': 'TRE', |
|||
'Treppe OG': 'TRO', |
|||
'Treppe oben': 'TRO' |
|||
} |
|||
light_map = { |
|||
'EZ': [ 0x03, 0x01 ], |
|||
'K': [ 0x03, 0x02 ], |
|||
'WZ1': [ 0x02, 0x01 ], |
|||
'WZ2': [ 0x02, 0x02 ], |
|||
'TER': [ 0x03, 0x03 ], |
|||
'FE': [ 0x03, 0x07 ], |
|||
'TRE': [ 0x02, 0x03 ], |
|||
'FO': [ 0x01, 0x03 ], |
|||
'TRO': [ 0x01, 0x07 ], |
|||
'KI1': [ 0x01, 0x06 ], |
|||
'KI2': [ 0x01, 0x04 ], |
|||
'SCH': [ 0x01, 0x08 ], |
|||
'B1': [ 0x01, 0x01 ], |
|||
'B2': [ 0x01, 0x02 ], |
|||
'EG1': [ 0x02, 0x09 ], |
|||
'EG2': [ 0x03, 0x09 ], |
|||
'OG': [ 0x01, 0x09 ], |
|||
'ALL': [ 0xFF, 0x09 ], |
|||
} |
|||
cmd_map = { |
|||
'off': 0, |
|||
'0': 0, |
|||
'on': 1, |
|||
'1': 1, |
|||
'value': 2, |
|||
'toggle': 3 |
|||
} |
|||
|
|||
|
|||
def decon(msg_id): |
|||
msg_prio=msg_id>>26 |
|||
msg_type=(msg_id>>24) & 0x03 |
|||
msg_dst=(msg_id>>16) & 0xFF |
|||
msg_src=(msg_id>>8) & 0xFF |
|||
msg_cmd=msg_id & 0xFF |
|||
# print("msg_id: ", hex(msg_id), "prio: ", hex(msg_prio),"type: ", hex(msg_type)," dst: ", hex(msg_dst)," src: ", hex(msg_src)," cmd: ",hex(msg_cmd)) |
|||
return [msg_prio, msg_type, msg_dst, msg_src, msg_cmd] |
|||
|
|||
def con(msg_dst,msg_cmd,msg_prio=3,msg_type=0,msg_src=11, ): |
|||
msg_id=(msg_prio<<26) + \ |
|||
((msg_type&0x03)<<24) +\ |
|||
((msg_dst&0xFF)<<16) +\ |
|||
((msg_src&0xFF)<<8) +\ |
|||
(msg_cmd&0xFF) |
|||
print("Constructed ID: "+hex(msg_id)) |
|||
return msg_id |
|||
|
|||
def on_connect(mcp_mqtt, userdata, flags, rc): |
|||
print("Connected with result code "+str(rc)) |
|||
|
|||
# Subscribing in on_connect() means that if we lose the connection and |
|||
# reconnect then subscriptions will be renewed. |
|||
mcp_mqtt.subscribe(sub_topic+"/+") |
|||
print("Subscribed to:"+sub_topic+"/+") |
|||
|
|||
def on_message(mcp_mqtt, userdata, msg): |
|||
local_bus=userdata |
|||
print("data Received topic: ", msg.topic) |
|||
m_decode=str(msg.payload.decode("utf-8","ignore")) |
|||
print("data Received",m_decode) |
|||
msg_cmd=cmd_map[m_decode] |
|||
sub=msg.topic[len(sub_topic)+1:] |
|||
light=aliases.get(sub,None) |
|||
if light is None: |
|||
light=sub |
|||
print("substring: "+light) |
|||
addr = light_map[light] |
|||
msg_id=con(msg_dst=addr[0],msg_cmd=msg_cmd) |
|||
msg_data=[addr[1]] |
|||
print(msg_data) |
|||
if msg_cmd == 2: |
|||
msg_data.append(value) |
|||
print(msg_data) |
|||
m = can.Message(arbitration_id=msg_id, |
|||
data=msg_data, |
|||
extended_id=True) |
|||
try: |
|||
local_bus.send(m) |
|||
except BaseException as e: |
|||
logging.error("Error sending can message {%s}: %s" % (m, e)) |
|||
print("data sent to CAN",m) |
|||
if light == 'ALL': |
|||
print("ALL detected") |
|||
for key in light_map: |
|||
mcp_mqtt.publish("light/"+key+"/state", msg_cmd, retain=1) |
|||
|
|||
|
|||
def main(): |
|||
verbosity = 2 |
|||
|
|||
logging_level_name = ['critical', 'error', 'warning', 'info', 'debug', 'subdebug'][min(5, verbosity)] |
|||
can.set_logging_level(logging_level_name) |
|||
|
|||
can_filters = [] |
|||
config = {"can_filters": can_filters, "single_handle": True} |
|||
config["interface"] = "socketcan_native" |
|||
config["bitrate"] = 125000 |
|||
bus = Bus("can1", **config) |
|||
|
|||
print('Connected to {}: {}'.format(bus.__class__.__name__, bus.channel_info)) |
|||
print('Can Logger (Started on {})\n'.format(datetime.now())) |
|||
|
|||
mcp_mqtt = mqtt.Client() |
|||
mcp_mqtt.on_connect = on_connect |
|||
mcp_mqtt.on_message = on_message |
|||
mcp_mqtt.user_data_set(bus) |
|||
mcp_mqtt.connect("mcp", 1883, 60) |
|||
mcp_mqtt.loop_start() |
|||
|
|||
try: |
|||
while True: |
|||
msg = bus.recv(1) |
|||
if msg is not None: |
|||
de=decon(msg.arbitration_id) |
|||
m= { "prio": hex(de[0]), "type": hex(de[1]), "dst": hex(de[2]), "src": hex(de[3]), "cmd": hex(de[4]), "action": hex(msg.data[0]) } |
|||
if de[2]==0 and de[4] == 6: |
|||
print("received state: ", hex(de[3]), hex(msg.data[0]), hex(msg.data[1])) |
|||
for key in light_map: |
|||
address=light_map[key] |
|||
if address[0] == de[3] and address[1] == msg.data[0]+1: |
|||
print("light/"+key+" changed to "+str(msg.data[1])) |
|||
mcp_mqtt.publish("light/"+key+"/state", msg.data[1] , retain=1) |
|||
except KeyboardInterrupt: |
|||
pass |
|||
finally: |
|||
bus.shutdown() |
|||
|
|||
if __name__ == "__main__": |
|||
main() |
@ -0,0 +1,214 @@ |
|||
#!/usr/bin/env python3 |
|||
|
|||
from __future__ import absolute_import, print_function |
|||
|
|||
import sys |
|||
import argparse |
|||
import socket |
|||
import logging |
|||
from datetime import datetime |
|||
|
|||
import can |
|||
from can import Bus, BusState, Logger |
|||
|
|||
import paho.mqtt.client as mqtt |
|||
|
|||
base_topic="house" |
|||
|
|||
coil_topic = "coil" |
|||
light_topic = "light" |
|||
switch_topic = "switch" |
|||
|
|||
coil_map = { |
|||
# tag, node, address, affinity |
|||
# tag: (L)ight, (E)G, (O)G, (F)lur, (S)chlaf, (A)ussen |
|||
'EZ': [ "LE", 0x03, 0x01 ], |
|||
'K': [ "LE", 0x03, 0x02 ], |
|||
'WZ1': [ "LE", 0x02, 0x01 ], |
|||
'WZ2': [ "LE", 0x02, 0x02 ], |
|||
'TER': [ "LEA", 0x03, 0x03 ], |
|||
'FE': [ "LFE", 0x03, 0x07 ], |
|||
'TRE': [ "LFE", 0x02, 0x03 ], |
|||
'FO': [ "LFO", 0x01, 0x03 ], |
|||
'TRO': [ "LFO", 0x01, 0x07 ], |
|||
'KI1': [ "LSO", 0x01, 0x06 ], |
|||
'KI2': [ "LSO", 0x01, 0x04 ], |
|||
'SCH': [ "LSO", 0x01, 0x08 ], |
|||
'B1': [ "LO", 0x01, 0x01 ], |
|||
'B2': [ "LO", 0x01, 0x02 ], |
|||
'ROL_EZ_G_DOWN': [ "", 0x03, 0x05, -1], |
|||
'ROL_EZ_G_UP': [ "", 0x03, 0x04, -1], |
|||
'ROL_EZ_N_DOWN': [ "", 0x03, 0x06, -2], |
|||
'ROL_EZ_N_UP': [ "", 0x03, 0x08, -2], |
|||
# 'EG1': [ 0, 0x02, 0x09 ], |
|||
# 'EG2': [ 0, 0x03, 0x09 ], |
|||
# 'OG': [ 0, 0x01, 0x09 ], |
|||
'ALL': [ "", 0xFF, 0x09 ], |
|||
} |
|||
|
|||
cmd_map = { |
|||
'off': 0, |
|||
'0': 0, |
|||
'on': 1, |
|||
'1': 1, |
|||
'value': 2, |
|||
'toggle': 3 |
|||
} |
|||
|
|||
|
|||
def decon(msg_id): |
|||
msg_prio=msg_id>>26 |
|||
msg_type=(msg_id>>24) & 0x03 |
|||
msg_dst=(msg_id>>16) & 0xFF |
|||
msg_src=(msg_id>>8) & 0xFF |
|||
msg_cmd=msg_id & 0xFF |
|||
# print("msg_id: ", hex(msg_id), "prio: ", hex(msg_prio),"type: ", hex(msg_type)," dst: ", hex(msg_dst)," src: ", hex(msg_src)," cmd: ",hex(msg_cmd)) |
|||
return [msg_prio, msg_type, msg_dst, msg_src, msg_cmd] |
|||
|
|||
def con(msg_dst,msg_cmd,msg_prio=3,msg_type=0,msg_src=11, ): |
|||
msg_id=(msg_prio<<26) + \ |
|||
((msg_type&0x03)<<24) +\ |
|||
((msg_dst&0xFF)<<16) +\ |
|||
((msg_src&0xFF)<<8) +\ |
|||
(msg_cmd&0xFF) |
|||
print("Constructed ID: "+hex(msg_id)) |
|||
return msg_id |
|||
|
|||
def coil_action(coil, payload, bus, tag=0 ): |
|||
try: |
|||
cmd=cmd_map[payload] |
|||
except BaseException as e: |
|||
logging.error("Error finding command {%s}: %s" % (payload, e)) |
|||
print("Coil: ",coil,"cmd:", payload) |
|||
try: |
|||
addr = coil_map[coil] |
|||
print("Addr:", addr) |
|||
if cmd == 2: |
|||
print("TBD") |
|||
# msg_data.append(value) |
|||
print("cmd", cmd,"length: ", len(addr)) |
|||
if tag is not 0: |
|||
if tag not in addr[0]: |
|||
print("not tagged with: ",tag) |
|||
return |
|||
|
|||
if cmd is not 0 and len(addr) is 4: |
|||
print("Applying affinity") |
|||
for key, value in coil_map.items(): |
|||
print("checking: ", key) |
|||
if len(value) is 4: |
|||
print("value_2 is", value[3], "Addr: ", addr[3]) |
|||
if value[3] is addr[3]: |
|||
msg_id=con(msg_dst=value[1],msg_cmd=0) |
|||
msg_data=[value[2]] |
|||
m = can.Message(arbitration_id=msg_id, |
|||
data=msg_data, |
|||
extended_id=True) |
|||
try: |
|||
bus.send(m) |
|||
print("data sent to CAN",m) |
|||
except BaseException as e: |
|||
logging.error("Error sending can message {%s}: %s" % (m, e)) |
|||
|
|||
msg_id=con(msg_dst=addr[1],msg_cmd=cmd) |
|||
msg_data=[addr[2]] |
|||
print(msg_id) |
|||
m = can.Message(arbitration_id=msg_id, |
|||
data=msg_data, |
|||
extended_id=True) |
|||
try: |
|||
bus.send(m) |
|||
print("data sent to CAN",m) |
|||
except BaseException as e: |
|||
logging.error("Error sending can message {%s}: %s" % (m, e)) |
|||
|
|||
except BaseException as e: |
|||
logging.error("Error finding coil %s" % (coil)) |
|||
|
|||
def on_connect(mcp_mqtt, userdata, flags, rc): |
|||
print("Connected with result code "+str(rc)) |
|||
|
|||
# Subscribing in on_connect() means that if we lose the connection and |
|||
# reconnect then subscriptions will be renewed. |
|||
mcp_mqtt.subscribe(base_topic+"/#", 0) |
|||
print("Subscribed to: "+base_topic+"/#") |
|||
|
|||
def on_message_coil(mcp_mqtt, bus, msg): |
|||
print("data Received topic: ", msg.topic) |
|||
m_decode=str(msg.payload.decode("utf-8","ignore")) |
|||
print("data Received",m_decode) |
|||
sub=msg.topic[len(base_topic)+len(coil_topic)+2:] |
|||
coil_action(sub, m_decode, bus) |
|||
|
|||
|
|||
def on_message_light(mcp_mqtt, bus, msg): |
|||
print("data Received topic: ", msg.topic) |
|||
m_decode=str(msg.payload.decode("utf-8","ignore")) |
|||
print("data Received",m_decode) |
|||
sub=msg.topic[len(base_topic)+len(light_topic)+2:] |
|||
coil_action(sub, m_decode, bus, "L") |
|||
|
|||
|
|||
def on_message(mcp_mqtt, obj, msg): |
|||
# This callback will be called for messages that we receive that do not |
|||
# match any patterns defined in topic specific callbacks, i.e. in this case |
|||
print(msg.topic + " " + str(msg.qos) + " " + str(msg.payload)) |
|||
|
|||
|
|||
def main(): |
|||
verbosity = 2 |
|||
|
|||
logging_level_name = ['critical', 'error', 'warning', 'info', 'debug', 'subdebug'][min(5, verbosity)] |
|||
can.set_logging_level(logging_level_name) |
|||
|
|||
can_filters = [] |
|||
config = {"can_filters": can_filters, "single_handle": True} |
|||
config["interface"] = "socketcan" |
|||
config["bitrate"] = 125000 |
|||
bus = Bus("can1", **config) |
|||
|
|||
print('Connected to {}: {}'.format(bus.__class__.__name__, bus.channel_info)) |
|||
print('Can Logger (Started on {})\n'.format(datetime.now())) |
|||
|
|||
mcp_mqtt = mqtt.Client() |
|||
mcp_mqtt.on_connect = on_connect |
|||
# mcp_mqtt.on_message = on_message |
|||
mcp_mqtt.user_data_set(bus) |
|||
mcp_mqtt.loop_start() |
|||
|
|||
mcp_mqtt.message_callback_add(base_topic+"/"+coil_topic+"/+", on_message_coil) |
|||
mcp_mqtt.message_callback_add(base_topic+"/"+light_topic+"/+", on_message_light) |
|||
mcp_mqtt.on_message = on_message |
|||
mcp_mqtt.connect("mcp", 1883, 60) |
|||
|
|||
mcp_mqtt.loop_start() |
|||
#mcp_mqtt.loop_forever() |
|||
|
|||
|
|||
try: |
|||
while True: |
|||
msg = bus.recv(1) |
|||
if msg is not None: |
|||
de=decon(msg.arbitration_id) |
|||
m= { "prio": hex(de[0]), "type": hex(de[1]), "dst": hex(de[2]), "src": hex(de[3]), "cmd": hex(de[4]), "action": hex(msg.data[0]) } |
|||
if de[2]==0 and de[4] == 6: |
|||
print("received state: ", hex(de[3]), hex(msg.data[0]), hex(msg.data[1])) |
|||
for key in coil_map: |
|||
address=coil_map[key] |
|||
if address[1] == de[3] and address[2] == msg.data[0]+1: |
|||
print("coil/"+key+" changed to "+str(msg.data[1])) |
|||
mcp_mqtt.publish(base_topic+"/"+coil_topic+"/"+key+"/state", msg.data[1] , retain=1) |
|||
if "L" in address[0]: |
|||
print("light/"+key+" changed to "+str(msg.data[1])) |
|||
mcp_mqtt.publish(base_topic+"/"+light_topic+"/"+key+"/state", msg.data[1] , retain=1) |
|||
elif de[2]==0 and de[4] == 5: |
|||
print("received state: ", de[3], msg.data[0], bin(msg.data[1])) |
|||
mcp_mqtt.publish(base_topic+"/"+switch_topic+"/"+str(de[3])+"-"+str(msg.data[0]), bin(msg.data[1]) , retain=1) |
|||
|
|||
except KeyboardInterrupt: |
|||
pass |
|||
finally: |
|||
bus.shutdown() |
|||
|
|||
if __name__ == "__main__": |
|||
main() |
@ -0,0 +1,55 @@ |
|||
#! /usr/bin/env python |
|||
import sys |
|||
import json |
|||
#stuff = json.loads(sys.argv[1]) |
|||
|
|||
|
|||
#data = json.load(sys.stdin) |
|||
|
|||
|
|||
#print(json.dumps(sys.stdin, sort_keys=True, indent=4)) |
|||
###print str(sys.argv[1]) |
|||
#print(stuff['foo']) |
|||
|
|||
#print(json.dumps(data, indent=4)) |
|||
|
|||
#msg_id=int(str(sys.argv[1]),0) |
|||
#msg_prio=msg_id>>26 |
|||
#msg_type=(msg_id>>24) & 0x03 |
|||
#msg_dst=(msg_id>>16) & 0xFF |
|||
#msg_src=(msg_id>>8) & 0xFF |
|||
#msg_cmd=msg_id & 0xFF |
|||
|
|||
#print "id:", hex(msg_id), bin(msg_id) |
|||
#print "prio:", hex(msg_prio), bin(msg_prio) |
|||
#print "type:", hex(msg_type), bin(msg_type) |
|||
#print "dst:", hex(msg_dst), bin(msg_dst) |
|||
#print "src:", hex(msg_src), bin(msg_src) |
|||
#print "cmd:", hex(msg_cmd), bin(msg_cmd) |
|||
import sys |
|||
import simplejson as json |
|||
|
|||
|
|||
def main(args): |
|||
try: |
|||
inputFile = open(args[1]) |
|||
input = json.load(inputFile) |
|||
inputFile.close() |
|||
except IndexError: |
|||
usage() |
|||
return False |
|||
if len(args) < 3: |
|||
print json.dumps(input, sort_keys = False, indent = 10) |
|||
else: |
|||
outputFile = open(args[2], "w") |
|||
json.dump(input, outputFile, sort_keys = False, indent = 4) |
|||
outputFile.close() |
|||
return True |
|||
|
|||
|
|||
def usage(): |
|||
print __doc__ |
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
sys.exit(not main(sys.argv)) |
@ -0,0 +1,149 @@ |
|||
#!/usr/bin/env python3 |
|||
|
|||
from __future__ import absolute_import, print_function |
|||
|
|||
import sys |
|||
import argparse |
|||
import socket |
|||
from datetime import datetime |
|||
|
|||
import can |
|||
from can import Bus, BusState, Logger |
|||
|
|||
import paho.mqtt.client as mqtt |
|||
|
|||
sub_topic = "shutter" |
|||
aliases = { |
|||
'Esszimmer_Garten': 'EZ_G', |
|||
'Esszimmer_Nachbar': 'EZ_N', |
|||
'Wohnzimmer1': 'WZ1', |
|||
'Wohnzimmer2': 'WZ2', |
|||
'Wohnzimmer3': 'WZ3', |
|||
'Wohnzimmer4': 'WZ4', |
|||
} |
|||
event_map = { |
|||
'stop': 0, |
|||
'off': 0, |
|||
'up': 1, |
|||
'down': 2 |
|||
} |
|||
coil_map = { |
|||
# up , down |
|||
'EZ_G': [ 0x03, 0x04 , 0x03, 0x05 ], |
|||
'EZ_N': [ 0x03, 0x08 , 0x03, 0x06 ], |
|||
'WZ1': [ 0x00, 0x01 , 0x00, 0x01 ], |
|||
'WZ2': [ 0x00, 0x01 , 0x00, 0x01 ], |
|||
'WZ3': [ 0x00, 0x01 , 0x00, 0x01 ], |
|||
'WZ4': [ 0x00, 0x01 , 0x00, 0x01 ] |
|||
} |
|||
cmd_map = { |
|||
'off': 0, |
|||
'on': 1, |
|||
'value': 2, |
|||
'toggle': 3 |
|||
} |
|||
|
|||
|
|||
def decon(msg_id): |
|||
msg_prio=msg_id>>26 |
|||
msg_type=(msg_id>>24) & 0x03 |
|||
msg_dst=(msg_id>>16) & 0xFF |
|||
msg_src=(msg_id>>8) & 0xFF |
|||
msg_cmd=msg_id & 0xFF |
|||
print("msg_id: ", hex(msg_id), "prio: ", hex(msg_prio),"type: ", hex(msg_type)," dst: ", hex(msg_dst)," src: ", hex(msg_src)," cmd: ",hex(msg_cmd)) |
|||
return [msg_prio, msg_type, msg_dst, msg_src, msg_cmd] |
|||
|
|||
def con(msg_dst,msg_cmd,msg_prio=3,msg_type=0,msg_src=11, ): |
|||
msg_id=(msg_prio<<26) + \ |
|||
((msg_type&0x03)<<24) +\ |
|||
((msg_dst&0xFF)<<16) +\ |
|||
((msg_src&0xFF)<<8) +\ |
|||
(msg_cmd&0xFF) |
|||
print("Constructed ID: "+hex(msg_id)) |
|||
return msg_id |
|||
|
|||
def on_connect(mcp_mqtt, userdata, flags, rc): |
|||
print("Connected with result code "+str(rc)) |
|||
|
|||
# Subscribing in on_connect() means that if we lose the connection and |
|||
# reconnect then subscriptions will be renewed. |
|||
mcp_mqtt.subscribe(sub_topic+"/+") |
|||
print("Subscribed to:"+sub_topic+"/+") |
|||
|
|||
def on_message(mcp_mqtt, userdata, msg): |
|||
local_bus=userdata |
|||
print("data Received topic: ", msg.topic) |
|||
m_decode=str(msg.payload.decode("utf-8","ignore")) |
|||
print("data Received",m_decode) |
|||
data=m_decode |
|||
sub=msg.topic[len(sub_topic)+1:] |
|||
event=event_map[data] |
|||
coils={ |
|||
'up': [ coil_map[sub][0], coil_map[sub][1] ], |
|||
'down': [ coil_map[sub][2], coil_map[sub][3] ] |
|||
} |
|||
if event is not None: # it's 0,1,2 |
|||
for key, value in coils.items(): |
|||
msg_id=con(msg_dst=value[0],msg_cmd=0) |
|||
msg_data=[value[1]] |
|||
print("turning off: ",sub,value[0],value[1]) |
|||
m = can.Message(arbitration_id=msg_id, |
|||
data=msg_data, |
|||
extended_id=True) |
|||
print("going to sent to CAN",m) |
|||
try: |
|||
local_bus.send(m) |
|||
except BaseException as e: |
|||
logging.error("Error sending can message {%s}: %s" % (m, e)) |
|||
print("data sent to CAN",m) |
|||
if event is not 0: |
|||
addr = coils[data] |
|||
print("turning on: ",addr[0],addr[1]) |
|||
msg_id=con(msg_dst=addr[0],msg_cmd=1) |
|||
msg_data=[addr[1]] |
|||
print(msg_data) |
|||
m = can.Message(arbitration_id=msg_id, |
|||
data=msg_data, |
|||
extended_id=True) |
|||
print("going to sent to CAN",m) |
|||
|
|||
try: |
|||
local_bus.send(m) |
|||
except BaseException as e: |
|||
logging.error("Error sending can message {%s}: %s" % (m, e)) |
|||
print("data sent to CAN",m) |
|||
|
|||
|
|||
|
|||
|
|||
def main(): |
|||
verbosity = 2 |
|||
|
|||
logging_level_name = ['critical', 'error', 'warning', 'info', 'debug', 'subdebug'][min(5, verbosity)] |
|||
can.set_logging_level(logging_level_name) |
|||
|
|||
can_filters = [] |
|||
config = {"can_filters": can_filters, "single_handle": True} |
|||
config["interface"] = "socketcan" |
|||
config["bitrate"] = 125000 |
|||
bus = Bus("can1", **config) |
|||
|
|||
print('Connected to {}: {}'.format(bus.__class__.__name__, bus.channel_info)) |
|||
print('Can Logger (Started on {})\n'.format(datetime.now())) |
|||
|
|||
mcp_mqtt = mqtt.Client() |
|||
mcp_mqtt.on_connect = on_connect |
|||
mcp_mqtt.on_message = on_message |
|||
mcp_mqtt.user_data_set(bus) |
|||
mcp_mqtt.connect("mcp", 1883, 60) |
|||
|
|||
try: |
|||
while True: |
|||
mcp_mqtt.loop() |
|||
except KeyboardInterrupt: |
|||
pass |
|||
finally: |
|||
bus.shutdown() |
|||
|
|||
if __name__ == "__main__": |
|||
main() |
@ -0,0 +1,141 @@ |
|||
#!/usr/bin/env python3 |
|||
# coding: utf-8 |
|||
|
|||
from __future__ import absolute_import, print_function |
|||
|
|||
import sys |
|||
import argparse |
|||
import socket |
|||
from datetime import datetime |
|||
|
|||
import can |
|||
from can import Bus, BusState, Logger |
|||
|
|||
import paho.mqtt.client as mqtt |
|||
|
|||
topic = "sunevents" |
|||
event_map = { |
|||
'sunrise': "up", |
|||
'night': "down", |
|||
} |
|||
coil_map = { |
|||
'ROL_EZ_DOWN': [0x03,0x05], |
|||
'ROL_EZ_UP': [0x03,0x04] |
|||
} |
|||
group_map = { |
|||
'up': ['ROL_EZ_UP'], |
|||
'down': ['ROL_EZ_DOWN'] |
|||
} |
|||
cmd_map = { |
|||
'off': 0, |
|||
'on': 1, |
|||
'value': 2, |
|||
'toggle': 3 |
|||
} |
|||
|
|||
|
|||
def decon(msg_id): |
|||
msg_prio=msg_id>>26 |
|||
msg_type=(msg_id>>24) & 0x03 |
|||
msg_dst=(msg_id>>16) & 0xFF |
|||
msg_src=(msg_id>>8) & 0xFF |
|||
msg_cmd=msg_id & 0xFF |
|||
# print("msg_id: ", hex(msg_id), "prio: ", hex(msg_prio),"type: ", hex(msg_type)," dst: ", hex(msg_dst)," src: ", hex(msg_src)," cmd: ",hex(msg_cmd)) |
|||
return [msg_prio, msg_type, msg_dst, msg_src, msg_cmd] |
|||
|
|||
def con(msg_dst,msg_cmd,msg_prio=3,msg_type=0,msg_src=11, ): |
|||
msg_id=(msg_prio<<26) + \ |
|||
((msg_type&0x03)<<24) +\ |
|||
((msg_dst&0xFF)<<16) +\ |
|||
((msg_src&0xFF)<<8) +\ |
|||
(msg_cmd&0xFF) |
|||
print("Constructed ID: "+hex(msg_id)) |
|||
return msg_id |
|||
|
|||
def on_connect(mcp_mqtt, userdata, flags, rc): |
|||
print("Connected with result code "+str(rc)) |
|||
|
|||
# Subscribing in on_connect() means that if we lose the connection and |
|||
# reconnect then subscriptions will be renewed. |
|||
mcp_mqtt.subscribe(topic) |
|||
print("Subscribed to:",topic) |
|||
|
|||
def on_message(mcp_mqtt, userdata, msg): |
|||
local_bus=userdata |
|||
print("data Received topic: ", msg.topic) |
|||
m_decode=str(msg.payload.decode("utf-8","ignore")) |
|||
print("data Received",m_decode) |
|||
data=m_decode |
|||
event=event_map[data] |
|||
if event is not None: |
|||
# event=sub |
|||
for key, value in coil_map.items(): |
|||
msg_id=con(msg_dst=value[0],msg_cmd=0) |
|||
msg_data=[value[1]] |
|||
print("turning off: ",key,value[0],value[1]) |
|||
m = can.Message(arbitration_id=msg_id, |
|||
data=msg_data, |
|||
extended_id=True) |
|||
print("going to sent to CAN",m) |
|||
try: |
|||
local_bus.send(m) |
|||
except BaseException as e: |
|||
logging.error("Error sending can message {%s}: %s" % (m, e)) |
|||
print("data sent to CAN",m) |
|||
|
|||
print("Group: ",event) |
|||
for coil in group_map[event]: |
|||
print("turning on", coil) |
|||
addr = coil_map[coil] |
|||
msg_id=con(msg_dst=addr[0],msg_cmd=1) |
|||
msg_data=[addr[1]] |
|||
print(msg_data) |
|||
m = can.Message(arbitration_id=msg_id, |
|||
data=msg_data, |
|||
extended_id=True) |
|||
print("going to sent to CAN",m) |
|||
|
|||
try: |
|||
local_bus.send(m) |
|||
except BaseException as e: |
|||
logging.error("Error sending can message {%s}: %s" % (m, e)) |
|||
print("data sent to CAN",m) |
|||
|
|||
|
|||
def main(): |
|||
verbosity = 2 |
|||
|
|||
logging_level_name = ['critical', 'error', 'warning', 'info', 'debug', 'subdebug'][min(5, verbosity)] |
|||
can.set_logging_level(logging_level_name) |
|||
|
|||
can_filters = [] |
|||
config = {"can_filters": can_filters, "single_handle": True} |
|||
config["interface"] = "socketcan" |
|||
config["bitrate"] = 125000 |
|||
bus = Bus("can1", **config) |
|||
|
|||
print('Connected to {}: {}'.format(bus.__class__.__name__, bus.channel_info)) |
|||
print('Can Logger (Started on {})\n'.format(datetime.now())) |
|||
|
|||
mcp_mqtt = mqtt.Client() |
|||
mcp_mqtt.on_connect = on_connect |
|||
mcp_mqtt.on_message = on_message |
|||
mcp_mqtt.user_data_set(bus) |
|||
mcp_mqtt.connect("mcp", 1883, 60) |
|||
|
|||
try: |
|||
while True: |
|||
mcp_mqtt.loop_start() |
|||
msg = bus.recv(1) |
|||
if msg is not None: |
|||
de=decon(msg.arbitration_id) |
|||
m= { "prio": hex(de[0]), "type": hex(de[1]), "dst": hex(de[2]), "src": hex(de[3]), "cmd": hex(de[4]), "action": hex(msg.data[0]) } |
|||
# print(m) |
|||
# mcp_mqtt.publish("can/rx", str(m)) |
|||
except KeyboardInterrupt: |
|||
pass |
|||
finally: |
|||
bus.shutdown() |
|||
|
|||
if __name__ == "__main__": |
|||
main() |