📄 commrs232.lst
字号:
635 /********************************************************************************************************
636 ** 函数名称: void rs232_commright(void)
637 ** 功能描述:
638 ** 输 入: 无
639 ** 输 出: 无
640 ** 全局变量:
641 ** 调用模块:
642 **
643 ** 作 者: 李伟
644 ** 日 期: 2008年12月20日
645 **-------------------------------------------------------------------------------------------------------
646 ** 修 改 人:
647 ** 日 期:
648 **-------------------------------------------------------------------------------------------------------
649 ********************************************************************************************************/
650 void rs232_commright(void)
651 {
652 1 rs_send_byte(0x7E); //报文头
653 1 Rs232ComCalculChkSum = 0;
654 1 Rs232CommSendByteWithChk((uint8)(ModeSysConfig[8])); //BoardAddress地址范围0~16
655 1 Rs232CommSendByteWithChk(Rs232CommCid); //CID 07
656 1 Rs232CommSendWordWithChk(0xA006); //LENTH
657 1 Rs232CommSendByteWithChk(0x01); //
658 1 Rs232CommSendWordWithChk(0x0001); //写系数正确
659 1 Rs232ComCalculChkSum = (~Rs232ComCalculChkSum)+1;
660 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum>>8));
661 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum));
662 1 rs_send_byte(0x0D);
663 1 while (rs_f_TI == 0); //等待最后一个字节发送完毕
664 1 }
665 /********************************************************************************************************
666 ** 函数名称: void rs232_commwrong(void)
667 ** 功能描述:
668 ** 输 入: 无
669 ** 输 出: 无
670 ** 全局变量:
671 ** 调用模块:
672 **
673 ** 作 者: 李伟
674 ** 日 期: 2008年12月20日
675 **-------------------------------------------------------------------------------------------------------
C51 COMPILER V7.06 COMMRS232 10/30/2008 13:20:06 PAGE 12
676 ** 修 改 人:
677 ** 日 期:
678 **-------------------------------------------------------------------------------------------------------
679 ********************************************************************************************************/
680 void rs232_commwrong(void)
681 {
682 1 rs_send_byte(0x7E); //报文头
683 1 Rs232ComCalculChkSum = 0;
684 1 Rs232CommSendByteWithChk((uint8)(ModeSysConfig[8])); //BoardAddress地址范围0~16
685 1 Rs232CommSendByteWithChk(Rs232CommCid); //CID 07
686 1 Rs232CommSendWordWithChk(0xA006); //LENTH
687 1 Rs232CommSendByteWithChk(0x01); //
688 1 Rs232CommSendWordWithChk(0x0000); //写系数错误
689 1 Rs232ComCalculChkSum = (~Rs232ComCalculChkSum)+1;
690 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum>>8));
691 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum));
692 1 rs_send_byte(0x0D);
693 1 while (rs_f_TI == 0);
694 1 }
695 /********************************************************************************************************
696 ** 函数名称: void Comm_rs232_handshake(void)
697 ** 功能描述:
698 ** 输 入: 无
699 ** 输 出: 无
700 ** 全局变量:
701 ** 调用模块:
702 **
703 ** 作 者: 李伟
704 ** 日 期: 2008年12月20日
705 **-------------------------------------------------------------------------------------------------------
706 ** 修 改 人:
707 ** 日 期:
708 **-------------------------------------------------------------------------------------------------------
709 ********************************************************************************************************/
710 void Comm_rs232_handshake(void)
711 {
712 1 rs_send_byte(0x7E); //报文头
713 1 Rs232ComCalculChkSum = 0;
714 1 Rs232CommSendByteWithChk((uint8)(ModeSysConfig[8])); //BoardAddress地址范围0~16
715 1 Rs232CommSendByteWithChk(Rs232CommCid); //CID 01
716 1 Rs232CommSendWordWithChk(0xA006); //LENTH
717 1 Rs232CommSendByteWithChk(0x01); //
718 1 Rs232CommSendWordWithChk(0x55AA);
719 1 Rs232ComCalculChkSum = (~Rs232ComCalculChkSum)+1;
720 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum>>8));
721 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum));
722 1 rs_send_byte(0x0D);
723 1 while (rs_f_TI == 0); //等待最后一个字节发送完毕
724 1 }
725 /********************************************************************************************************
726 ** 函数名称: void Comm_rs232_readanalog(void)
727 ** 功能描述:
728 ** 输 入: 无
729 ** 输 出: 无
730 ** 全局变量:
731 ** 调用模块:
732 **
733 ** 作 者: 李伟
734 ** 日 期: 2008年12月20日
735 **-------------------------------------------------------------------------------------------------------
736 ** 修 改 人:
737 ** 日 期:
C51 COMPILER V7.06 COMMRS232 10/30/2008 13:20:06 PAGE 13
738 **-------------------------------------------------------------------------------------------------------
739 ********************************************************************************************************/
740 void Comm_rs232_readanalog(void)
741 {
742 1 uint8 i;
743 1 rs_send_byte(0x7E); //报文头
744 1 Rs232ComCalculChkSum = 0;
745 1 Rs232CommSendByteWithChk((uint8)(ModeSysConfig[8])); //BoardAddress地址范围0~16
746 1 Rs232CommSendByteWithChk(Rs232CommCid); //CID 02
747 1 Rs232CommSendWordWithChk(0xF05C); //LENTH
748 1 Rs232CommSendByteWithChk(0x01); //
749 1 for(i = 0;i < 15;i++) //15只池电电压
750 1 {
751 2 Rs232CommSendWordWithChk(CellVoltage[i]);
752 2 }
753 1 Rs232CommSendByteWithChk(0x02); //
754 1 for(i = 0;i < 9;i++) //15只电池温度,1路环境温度
755 1 {
756 2 CommSendByteWithChk(Temperature[i]);
757 2 }
758 1 Rs232CommSendByteWithChk(0x03);
759 1 Rs232CommSendWordWithChk(ChargeCurrent); //充电电流
760 1 Rs232CommSendWordWithChk(DisChargeCurrent); //放电电流
761 1 Rs232ComCalculChkSum = (~Rs232ComCalculChkSum)+1;
762 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum>>8));
763 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum));
764 1 rs_send_byte(0x0D);
765 1 while (rs_f_TI == 0); //等待最后一个字节发送完毕
766 1 }
767 /********************************************************************************************************
768 ** 函数名称: void Comm_rs232_read_digital(void)
769 ** 功能描述:
770 ** 输 入: 无
771 ** 输 出: 无
772 ** 全局变量:
773 ** 调用模块:
774 **
775 ** 作 者: 李伟
776 ** 日 期: 2008年12月20日
777 **-------------------------------------------------------------------------------------------------------
778 ** 修 改 人:
779 ** 日 期:
780 **-------------------------------------------------------------------------------------------------------
781 ********************************************************************************************************/
782 void Comm_rs232_read_digital(void)
783 {
784 1 rs_send_byte(0x7E); //报文头
785 1 Rs232ComCalculChkSum = 0;
786 1 Rs232CommSendByteWithChk((uint8)(ModeSysConfig[8])); //BoardAddress地址范围0~16
787 1 Rs232CommSendByteWithChk(Rs232CommCid); //CID 03
788 1 Rs232CommSendWordWithChk(0x501A); //LENTH
789 1
790 1 Rs232CommSendByteWithChk(0x01); //
791 1 Rs232CommSendByteWithChk(ComAlarmET ); //综合告警
792 1 Rs232CommSendByteWithChk(ComAlarmVh0); //1~ 8只电池过压告警
793 1 Rs232CommSendByteWithChk(ComAlarmVh1); //9~15只电池过压告警
794 1 Rs232CommSendByteWithChk(ComAlarmVl0); //1~ 8只电池欠压告警
795 1 Rs232CommSendByteWithChk(ComAlarmVl1); //9~15只电池欠压告警
796 1 Rs232CommSendByteWithChk(ComAlarmScCTh); //1~15只电池充电过温
797 1 Rs232CommSendByteWithChk(ComAlarmScCTl); //1~15只电池充电欠温
798 1 Rs232CommSendByteWithChk(ComAlarmSDcTh); //1~15只电池放电过温
799 1 Rs232CommSendByteWithChk(ComAlarmSDcTl); //1~15只电池放电欠温
C51 COMPILER V7.06 COMMRS232 10/30/2008 13:20:06 PAGE 14
800 1 Rs232CommSendByteWithChk(ComTemperaSensor ); //1~ 8路温度传感器失效
801 1 Rs232CommSendByteWithChk(ComVoltageSensor0); //电压传感器失效
802 1
803 1 Rs232ComCalculChkSum = (~Rs232ComCalculChkSum)+1;
804 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum>>8));
805 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum));
806 1 rs_send_byte(0x0D);
807 1 while (rs_f_TI == 0); //等待最后一个字节发送完毕
808 1 }
809 /********************************************************************************************************
810 ** 函数名称: void Comm_rs232_read_config(void)
811 ** 功能描述:
812 ** 输 入: 无
813 ** 输 出: 无
814 ** 全局变量:
815 ** 调用模块:
816 **
817 ** 作 者: 李伟
818 ** 日 期: 2008年12月20日
819 **-------------------------------------------------------------------------------------------------------
820 ** 修 改 人:
821 ** 日 期:
822 **-------------------------------------------------------------------------------------------------------
823 ********************************************************************************************************/
824 void Comm_rs232_read_config(void)
825 {
826 1 uint8 i;
827 1 rs_send_byte(0x7E); //报文头
828 1 Rs232ComCalculChkSum = 0;
829 1 Rs232CommSendByteWithChk((uint8)(ModeSysConfig[8])); //BoardAddress地址范围0~16
830 1 Rs232CommSendByteWithChk(Rs232CommCid); //CID 05
831 1 Rs232CommSendWordWithChk(0x9052); //LENTH
832 1 Rs232CommSendByteWithChk(0x01); //电压限值配置信息
833 1 for(i = 0;i < 9;i++)
834 1 {
835 2 Rs232CommSendWordWithChk(ModeSysConfig[i]);
836 2 }
837 1 Rs232CommSendByteWithChk(0x02); //温度限值配置信息
838 1 for(i = 0;i < 12;i++)
839 1 {
840 2 Rs232CommSendByteWithChk(ModeTempCofing[i]);
841 2 }
842 1 Rs232CommSendByteWithChk(0x03); //系数
843 1 Rs232CommSendWordWithChk(CUK);
844 1 Rs232CommSendWordWithChk(CTK);
845 1 Rs232CommSendWordWithChk(OTK);
846 1 Rs232ComCalculChkSum = (~Rs232ComCalculChkSum)+1;
847 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum>>8));
848 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum));
849 1 rs_send_byte(0x0D);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -